Hi,
I am writing a swing based application which appends rows of components to a JPanel.
The JPanel is within a JScrollPane.
Currently I have set the components up like this:
private Dimension mainPanelSize = new Dimension(780,3500);
//....
panelMain = createNewMainPanel();
panelMain.setPreferredSize(mainPanelSize);
//...........
jsp = new JScrollPane(panelMain, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
jsp.setPreferredSize(new Dimension(800,690 - adjustment));
container.add(jsp);
This setup means that the main panel is a fixed size (it is quite large but you can't scroll down forever). If I remove the line setting a preferred size of panelMain, when a new row of components is added it goes off the side of the panel (the panel increases horizontally), rather than being added below (increasing vertically).
What I would like to do is set a preferred width of panelMain, but allow the height to grow when new rows are added. Is this possible?