Lescha
asked on
Redrawing JFrame
I have an application written in JB3. At some point of execution, I call invalidate() method of the main window (which in this case extends JFrame) but it doesn't do anything. Why is that?
Also: I tried setBackground() method on the same main window. It works fine on Buttons and such, but on the JFrame it does the following: it changes the color for an instant (I can see the flicker) and then changes it back to light gray. Why is that?
Also: I tried setBackground() method on the same main window. It works fine on Buttons and such, but on the JFrame it does the following: it changes the color for an instant (I can see the flicker) and then changes it back to light gray. Why is that?
ASKER
Thanks, please lock the question!
Jim, isn't the content pane transparent?
Lescha: you can click on the "Accept Comment as answer" on the title bar of Jim's comment.
ASKER
There is no such button on it. Don't know why, it is usually there.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
As for JFrame background, while it is true that JFrame extends Component and so has a setBackground method, it is JFrame's content pane that you are actually viewing. The flicker is due to the fact that JFrame tries to draw its background and then redraws its children which causes its content pane to draw over. Call setBackground on the JFrame's content pane and that will fix this problem:
frame.getContentPane().set
Best regards,
Jim Cakalic