This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Java swing application not repainting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java swing application not repainting" Watch "Java swing application not repainting" New topic
Author

Java swing application not repainting

Braden Steffaniak
Greenhorn

Joined: Jun 03, 2011
Posts: 15
I have a java application that should be repainting all the time, however, only repaints once.

heres the method that runs continuously through a infinite loop:



And heres the paintComponent method:



It only prints "testing" once... then never again. On the other hand, it prints "asdf" continuously. What am I doing wrong?
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2152
    
    7
We can't tell what you are doing wrong based on a few lines of code because we don't know the context of how/when the code is executed.

Maybe your loop is running on the Event Dispatch Thread and you are preventing the frame from repainting itself since the repaint will only be done when the loop is finished executing.

Use a Swing Timer to schedule animation/repainting.

Post your SSCCE that demonstrates the problem.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java swing application not repainting
 
Similar Threads
JPanel not repainting properly.
paintComponent() Method?
rotating text inside a jlabel
Head First Java problem
JPanel size