• Post Reply Bookmark Topic Watch Topic
  • New Topic

How much overhead in the associated Paint methods  RSS feed

 
Tom Landry
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since the Paint methods are being executed anytime a frame is being moved or resized, how much overhead could an application incur if the application
- has many frames
- doing a lot of moving
- doing a lot of resizing
- has a lot of background processes running.

As a rule, I try to only keep the most essential code in these types of methods and wondering if that type of thinking is "old school".

How much overhead is actually involved?
If you needed to monitor the size of a given frame anytime the user resizes it, would you be concerned that using these methods would incur too much overhead?
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tom Landry wrote:If you needed to monitor the size of a given frame anytime the user resizes it, would you be concerned that using these methods would incur too much overhead?


No. Just monitoring a couple of attributes of an object? That would be trivial.
 
Stephan van Hulst
Saloon Keeper
Posts: 6988
110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that moving a frame is no problem. I think the paint data of the frame is stored in the GPU's memory, even if another frame is dragged over it. Only parts that are dragged over the edge of the screen get lost, and are repainted when you drag them back on screen.
 
Tom Landry
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a scenario where you may opt not to utilize the Paint functionality or only use it only sparingly?
Something like a real-time application of sorts?
 
Stephan van Hulst
Saloon Keeper
Posts: 6988
110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you worrying about all of this so much? Are you experiencing performance problems? Don't optimize prematurely, or you'll end up doing unnecessary work. The UI system is actually very smart in avoiding doing too much work. Write the application, and once it functions, deal with performance issues.
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tom Landry wrote:As a rule, I try to only keep the most essential code in these types of methods...


However this part of your post is a good idea. The paint() method (or paintComponent() if your component has one) should be dedicated to, um, painting the component. Other code should certainly be looked at skeptically, but you don't have to go overboard. Updating a database row might be okay in many circumstances, for example. But displaying a dialog box would never be okay.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!