File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes repaint() becomes slower as program runs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "repaint() becomes slower as program runs" Watch "repaint() becomes slower as program runs" New topic
Author

repaint() becomes slower as program runs

Jerry Brigman
Greenhorn

Joined: Nov 10, 2011
Posts: 1
Hello All,

I am seeing some weird behavior in repaint(); My code displays png or jpg icons in a JLayeredPane over the top of a background image after querying a set of switches on an embedded computer over ethernet. The response time of the repaint(); method seems to become slower as the program runs. The problem seems to be more pronounced when I use PNGs with transparency. If I dump the raw data from the incoming packet to the screen into a JLabel, it seems to maintain its speed as long as the program runs. Has anyone ever experienced this? I have pored over the internet and exhausted the Java books that I currently own and seem to have come up dry.

These are the parts of the code where I think the problem might be:

I created a MyDipswitchDraw object called dipSwitchDraw and access it from this method. dipSwitchData[4] is the position of the data in the incoming packet that I am operating on. I am also using this method to report how long it takes to complete. It seems to report around 50000nS when only the command line is displayed, but over time while the Java GUI is displayed, as the switches are actuated, the delay time increases from 50000ns to over 2000000nS


Thanks in advance to anyone who can help

Jerry

[Added code tags - see UseCodeTags for details]
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4527
    
    5

Probably not related to your problem, but you shouldn't dispose() a Graphics that you didn't create. And its usual for a painting method override to start by invoking the super implementation.


luck, db
There are no new questions, but there may be new answers.
Przemek Boryka
Ranch Hand

Joined: Dec 06, 2011
Posts: 51

Hi!

Use paintComponent() method in JPanel



I hope this help
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1076
    
  10

Your post has a mistake. the paintComponent method should invoke super.paintComponent and not super.paintComponents
These are 2 different methods.

Przemek Boryka wrote:


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
Przemek Boryka
Ranch Hand

Joined: Dec 06, 2011
Posts: 51

Ranganathan Kaliyur Mannar wrote:Your post has a mistake. the paintComponent method should invoke super.paintComponent and not super.paintComponents
These are 2 different methods.

Przemek Boryka wrote:


Sorry, it is my fault, but I was close

Greeting from Poland
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: repaint() becomes slower as program runs