I have a GUI window with a JFrame. On this JFrame, I have a JPanel that completely covers the JFrame. I then have another JPanel within this first JPanel that contains a text box and 3 buttons. Within an event handler, I want to expand the JFrame and 2 JPanels by a height of 20 px. I then want to move down the text box and 3 buttons, 20 px.
I can expand the JFrame and the first JPanel with the following code snip. But, it doesn't work on the second panel nor does it work to move the button down.
Appreciate your help. Thanks..
// Make room for an additional text box
int heightInc = 20;
Dimension frameSize = new Dimension();
Rectangle rectangle = new Rectangle();
// Adjust JFrame size (This Works)
frameSize = this.getSize();
frameSize.height += heightInc;
this.setSize(frameSize);
// Adjust the bounding JPanel size (This Works)
frameSize = jplFrame.getSize();
frameSize.height += heightInc;
jplFrame.setPreferredSize(frameSize);
// Adjust the AddSubtitle JPanel size (This doesn't work)
frameSize = jplAddSubtitle.getSize();
frameSize.height += heightInc;
jplAddSubtitle.setPreferredSize(frameSize);
// Move the "Add Another" button down (This doesn't work)
rectangle = btnAddAnother.getBounds();
rectangle.y += heightInc;
btnAddAnother.setBounds(rectangle);