• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Question regarding Renderers

 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why is it that the Renderer get's called everytime you move your mouse over a Cell or TreeNode?
For example, I have a JTable and I have a TableCellRenderer that extends DefaultTableCellRenderer. In here I build my tooltip for each Row from information in a Database. What I have noticed though is that everytime I move my mouse around the JTable, the Tooltip get's built over and over which means my database get's queried over and over.
Is there anyway for the table to get rendered via this Renderer but only when the table is constructed the first time or refreshed?
Thanks.
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suspect it's needing to repaint because the sprite (arrow, cursor) passing over your component is causing little bits to need refreshing.
With my UI that is mostly a huge JTree, I implemented a feature whereby the nodes' toString returns a cached value rather than building the string over and over uneccesarily. You might consider doing the same, to eliminate all those database calls ...
just a thought,
Eric.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Eric. I have considered that. I am trying to get different opinions and suggestions regarding this before I start adding a lot more code. What I will probably end up doing is just using a cached result set. Then I can make the same calls on that instead of creating a whole new object to store my cached data.
Thanks again.
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with the caching idea.
AFAIK, JTables continually ask for getValue from the renderer as you move your cursor over them. JTrees, JLists, do not.
Bill
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic