is it possible to change the size (length & width) of a JPanel at runtime? I have a JFrame, inside it I have a JPanel (placed inside a jscrollPane) and a JButton. When pressing on the JButton I want the size of the JPanel to change taking random values for length and width. To do this, I used the following as the actionListener for the JButton :
public void actionPerformed(ActionEvent actionEvent) {
jPanel1.repaint();
jPanel1.revalidate();
}
and I tried to set the preferred size of the jPanel in the paintComponent() method taking random values for its dimension, but this didn't work. Any help would be appreciated.