• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDialog resize question

 
seema prakash
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic