Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Question regarding Renderers

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
Eric Blische
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • 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
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
Bill Liteplo
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • 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
 
Run away! Run away! Here, take this tiny ad with you:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!