I have swing application which does following:
public void init() {
jFrame = new JFrame();
...
jFrame.add(sortingDataInputComponent.asComponent());
...
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jFrame.pack();
jFrame.setVisible(true);
jFrame.toFront();
}
there sortingDataInputComponent is JPanel with
jPanel.setLayout(new BoxLayout(jPanel, BoxLayout.Y_AXIS));
inside of which there is another JPanel with
jPanel.setLayout(new GridLayout(0,numberOfColumns));
where
private final int numberOfColumns = 3;
and inner jpanel grows at button press:
jPanel.add(rowElement.getLabel(), insertionIndex);
jPanel.add(rowElement.getField(), insertionIndex + 1);
jPanel.add(rowElement.getDeleteButton(), insertionIndex + 2);
rowElements.add(rowElement);
jPanel.revalidate();
jPanel.repaint();
but the main windows does not grow with JPanel. It has the same initial size. How to make JFrame grow with the growth of inner JPanels?