This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JDialog resize question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JDialog resize question" Watch "JDialog resize question" New topic
Author

JDialog resize question

seema prakash
Ranch Hand

Joined: Nov 17, 2004
Posts: 59
Hi

I have a JDialog. I add components(label, buttons, checkbox, panel) to it. The panel holds
a scrollpane with a jtable. The table contents change depending on the checkbox selection.
The table shows 3 rows of data when the checkbox is not selected and 7 rows of data when the
check box is selected. I do not want the vertical scroll bars to be displayed instead would
like the dialog to change the size depending on the check box selection. Is this possible?
Any hints?

Thanks
Darrin Cartwright
Ranch Hand

Joined: Dec 27, 2002
Posts: 107
Hi seema,

Yes, it's possible. First, if the JScrollpane is not used, remove it from the panel. When you add or remove components from the dialog, call pack() to resize the dialog. This will cause the LayoutManager to layout the components again, and resize the dialog if needed.
Here is a sample dialog I did in Netbeans: take a look at the AddRemoveCheckBoxItemStateChanged method.



Notice that the LayoutManager determines how the dialog is resized.

Darrin
[ May 17, 2007: Message edited by: Darrin Cartwright ]

Life is good on the Ponderosa,<br />but mind where you step.
 
Don't get me started about those stupid light bulbs.
 
subject: JDialog resize question