How do you change the preferredSize() of a java program, after setVisible()? For example, you have a program that is 100x200, but when you click a button it changes to something else like 300x100.
Thanks in advance for any help.
How do you change the preferredSize() of a java program, after setVisible()? For example, you have a program that is 100x200, but when you click a button it changes to something else like 300x100.
Thanks in advance for any help.
Assuming you called setVisible method like this
new MyWindow().setVisible(true);
And your button's click event name is myButtonActionPerformed, then this code will work:
private void myButtonActionPerformed(java.awt.event.ActionEvent e) {
setSize(new java.awt.Dimension(300, 100));
}