• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

repaint() becomes slower as program runs

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 51
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

Use paintComponent() method in JPanel



I hope this help
 
Bartender
Posts: 1104
10
Netbeans IDE Java Ubuntu
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
I RELEASE YOU! (for now .... ) Feel free to peruse this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic