aspose file tools
The moose likes Java in General and the fly likes Java swing application not repainting Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply 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: 1808
    
    2
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://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Java swing application not repainting
 
Similar Threads
paintComponent() Method?
Head First Java problem
rotating text inside a jlabel
JPanel not repainting properly.
JPanel size