• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

repaint() becomes slower as program runs

 
Jerry Brigman
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5136
11
Java Netbeans IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Przemek Boryka
Ranch Hand
Posts: 51
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

Use paintComponent() method in JPanel



I hope this help
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your post has a mistake. the paintComponent method should invoke super.paintComponent and not super.paintComponents
These are 2 different methods.

Przemek Boryka wrote:
 
Przemek Boryka
Ranch Hand
Posts: 51
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic