Refresh view of the entire GUI

Xadina
Xadina used Ask the Experts™
on
HI!
I am building an interactive circuit application.  The menu bar displays a menu and allows the user to access a number of functions.  One of them is:
Refresh view of entire GUI.
I have searched for some code but I didn't find anything.
Can u help pls?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Java Developer
Top Expert 2010
Commented:
frame.repaint();

Though I'm not sure I understand why you need it?

Commented:
This will update every GUI object.  Say you have a JFrame named Frame and it is your 'main' window:

Frame.update( Frame.getGraphics() );

That should repaint everything contained within 'Frame' as well as 'Frame' itself.

Commented:
Oh... forgot to add that the 'update()' method is part of the java.awt.Container class and that the 'getGraphics()' method is part of the java.awt.Component class.
Announcing the Winners!

The results are in for the 15th Annual Expert Awards! Congratulations to the winners, and thank you to everyone who participated in the nominations. We are so grateful for the valuable contributions experts make on a daily basis. Click to read more about this year’s recipients!

Mick BarryJava Developer
Top Expert 2010

Commented:
> Frame.update( Frame.getGraphics() );


you should not call update (or paint) directly.

Author

Commented:
I need to referesh the view of the GUI, cos since the GUI lets the user draw a circuit, at any point he might want to start all over again. so he presses refresh.
Well, i have to do it, even if it doesn't make sense or it will loose me marks in the exam! :-)

Thanks.
Mick BarryJava Developer
Top Expert 2010

Commented:
> at any point he might want to start all over again.

Sorry misunderstood what you meant by refresh.
It sounds like what you want to do is clear what the user has previously drawn. What you need to do for this depends on how you have implemented your drawing.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial