• Post Reply Bookmark Topic Watch Topic
  • New Topic

JFrame resizing -- what is normal behavior?

 
Glenn Lasseigne
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

If I instantiate a JFrame that is about 60% of the screen and do nothing else, the content pane is nothing more than the CENTER of a BorderLayout set to default background color. Now, if I QUICKLY resize the window, I can observe black areas which are then filled with background color as appropriate. If I add more items to the BorderLayout (say 12 JButtons), the black areas are observable for longer periods of time, as it seems to take longer for the layout to do its job. I am running this on a new computer/monitor so there should be no issues there. Is this normal?

I ask because when I then use a JXPanel, the situation gets MUCH worse as the JXPanel changes the Repaint Manager.

Thanks in advance,

Glenn
 
Rob Camick
Ranch Hand
Posts: 2699
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post your SSCCE that demonstrates the problem. Then we can determine if the problem is with your code or Swing repainting.
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that it's a general Swing issue. I've seen it in my Swing applications on Windows Vista, though thankfully barely noticeable.
 
Glenn Lasseigne
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the replies.

I have been doing some investigations and would like to report my results and ask for
comments. Below is a very simple program involving a JFrame, a BorderLayout, and a bunch
of buttons. Nothing is rocket science, and one would suspect that everything should work
as expected. But, it doesn't. My eventual problem involves using a JXPanel and some horrendous
repaint behavior. I have not been able to reproduce this behavior in a small postable program yet,
but I believe it is related to the behavior below. The repainting behavior involving the JXPanel is
highly system dependent. I will post about this later.

I have tried the program on the following systems:
1) My home desktop running Windows 7.
a) This is a new computer (Dell) with very good monitor and graphics card (Not gaming).
2) My office computer running XP Professional
3) Dell laptop running Vista
4) Sony laptop running XP (four years old)

The steps that I take are the following:
1) Run the program
a) A small JFrame appears in the upper left corner of the screen.
2) Use the mouse to grab the lower right corner of the JFrame.
3) QUICKLY resize the JFrame to almost full size of the screen.
4) Observe repaint behavior.
5) In all cases, the final layout is correct!

The results are as follows:
1) On the Windows 7 machine
a) The new border of the JFrame is evident at the new position.
b) The space between the new border and the original layout is filled with black.
c) The layout "snaps" to the final position.
d) The "snapping" is delayed if a more complicated layout is used.

2) On the XP Professional machine
a) Behoviour is as expected -- immediate resizing of JFrame and layout
b) On more complicated layout, behavior is as below but "less".

3) On laptops (it is hard to resize quickly and screen size is smaller)
a) Multiple instances of the JFrame border in the intermediate positions are seen.
b) The area inbetween the original layout and the new border appear to be transparent
c) The final layout appears or "snaps" to new border.
d) Behavior is more pronounced on more complicated layout.

My analysis. The behavior seems to be the same except that Windows 7 erases the extra region between each
paint of the JFrame border rather than let it be transparent. Thus, you do not see the intermediate borders as
they have been erased.

I then performed the following experiment on the Windows 7 machine. All frames were reduced to a small size
and then quickly resized as above.
1) A Notepad frame - resizes nicely
2) An Opera browser frame -- Black areas are noticable as above.
3) An Eclipse IDE frame -- resizes nicely even though the layout is VERY complicated.
4) An Explorer browser -- resizes nicely except some black for one button (you would never notice if you weren't looking).


Questions:

What do the programs that don't show the visual artifacts of resizing do differently?
Why is their resizing continuous and mine and Opera's resizing "discrete"?




 
Glenn Lasseigne
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. There were no more comments, but in the meantime I (accidently) found out a few things and thought I would post what I have found
  • The black area found in the resizing results from translucency effects when using the Aero theme
  • For some reason, the translucency was temporarily disabled on my system, and the black areas disappeared and the resizing behavior was as on the other systems.


  • Can someone please comment on the behavior they get when resizing the JFrame when using the following code. I have
    found the results to be system dependent. On my Windows 7 -- using Aero and just plain Windows7 -- I get lots and
    lots of flicker. If I do not let go of the frame and just continue resizing, things get much worse and the flickering changes
    to completely blank areas. Contrast with the code from the previous post. Thanks in advance

     
    Michael Dunn
    Ranch Hand
    Posts: 4632
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    > Ok. There were no more comments...

    your first post (the one starting with package fadingpanel.jxpaneltest;)
    ran OK for me, didn't matter how quickly I resized it. vista/java 1.6.0_20

    the last post I cannot compile/run, I don't have the classes
    import org.jdesktop.swingx.JXPanel;

    not much point trying to do anything else with it, the problem might be JXPanel.
     
    Glenn Lasseigne
    Greenhorn
    Posts: 6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    > not much point trying to do anything else with it, the problem might be JXPanel.

    That was pretty much my point. I didn't want to use JXPanel if it was not safe. I was
    surprised to find so much system dependent behavior. It seems that Windows7 is doing
    something different, and the designers of JXPanel did not see it coming.

    I have designed a JXPanel like component using JXLayer and this seems to work. I
    posted on the JXLayer forum on java.net for verification that the component is designed
    OK. I am an advanced beginner at JAVA/OOP so I really am not sure about anything
    that I do.

    Thanks for your time and help.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!