Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Detect a JDialog has been fully displayed?

 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Relating to a question here, the row heights of the JTable are changed when the renderers are prepared by the JTable. I need to size the JDialog on opening to be just big enough to show the items I've put in the table. Problem is, I can't seem to find a way to know when the JTable has been properly sized (after it's called every renderer, basically) so that I can calculate the total size of the table by it's row heights.

If I just do it on windowOpening() I seem to get it before the row heights have been changed by the custom renderers, so it's too small. Just letting the JTable do the work isn't an option, they don't change/update their scrollable size.
 
Brian Cole
Author
Ranch Hand
Posts: 903
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The renderer isn't invoked until the
cell actually needs to be painted,
which is way too late for what you're
trying to do.

You may need to call your renderer's
getTableCellRendererComponent() method
manually.
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, this was my problem. It didn't occur to me that I had everything I needed to invoke the getTableCellRendererComponent() myself and that's all I really need. At a glance this seems to work beautifully for a modal dialog. populate() adds the initial data to the table and resize() calculates the total height of the rows and changes it's scrollable size to meet it.


[ October 27, 2005: Message edited by: Ken Blair ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic