The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.

Refreshing a window in Java

Steel AngelSteel Angel Registered User regular
edited June 2007 in Help / Advice Forum
So I'm working on some stuff for class including a basic digital clock in a GUI application when I realize that I'm not actually sure how to refresh a window. So far all I've done is manage to create infinite loops with while statements that require manual termination (the close button doesn't work) and don't flush the old numbers anyway.

How is this kind of thing normally handled? What are good approaches and classes to look up? I'm pretty new to GUI programming, hence taking this class.

For reference, I'm using Swing components and a Graphics object to create the window all this runs and displays in.

Edit: And my relative lack of understanding of how Java handles updates to a graphical window extends to splash screens as well. I understand that the SplashScreen object only creates a splash screen until a Swing menu is created. Since I'd like my splash screen to last more than a second, how would I go about delaying the rendering of the window the actual program displays stuff in?

Big Dookie wrote: »
I found that tilting it doesn't work very well, and once I started jerking it, I got much better results.

Steam Profile
3DS: 3454-0268-5595 Battle.net: SteelAngel#1772
Steel Angel on

Posts

  • Bob SappBob Sapp Registered User regular
    edited June 2007
    I'm pretty sure it's the repaint() method. It's part of the class called Component which most, if not all, swing classes derive from somewhere down the line.

    http://java.sun.com/javase/6/docs/api/java/awt/Component.html#repaint()

    The idea of the method is that it schedules the paint method to be called. This way you don't have to deal with setting up the Graphics object for the paint method.

    Bob Sapp on
    fizzatar.jpg
Sign In or Register to comment.