java expandable JDialog
问题 For my application I have a JDialog which contains a JPanel with some basic JTextFields and JButtons . The idea is to have a button which expands the JDialog to reveal a second JPanel which contains some "advance" settings. I have achieved this with calling setPreferredSize() and pack() , but this isn't very elegant. An "elegant" solution would be to set the second Panel to be somehow null and therefore to get ignored by pack() when the toggle state is in "retracted". Sorry that I can't