This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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?
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.