It's not a secret anymore!*
The moose likes Swing / AWT / SWT and the fly likes Detect a JDialog has been fully displayed? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Detect a JDialog has been fully displayed?" Watch "Detect a JDialog has been fully displayed?" New topic
Author

Detect a JDialog has been fully displayed?

Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
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

Joined: Sep 20, 2005
Posts: 862
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.


bitguru blog
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
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 ]
 
jQuery in Action, 2nd edition
 
subject: Detect a JDialog has been fully displayed?
 
Similar Threads
JTable(!!!)
jtable
JTable width and height
JTable
jtable not refreshing