Hi all,
I have a JPanel using FlowLayout, to which I add new JComponents during my program's run. When the JComponents run out of room horizontally, they place themselves on the next row down, as they ought to. However, the JPanel does not expand to fit them -- instead they disappear below the edge of the JPanel.
My addItem() method is very simple:
private someMethod(){
...
itemContainer = new JPanel();
itemContainer.setLayout(new FlowLayout());
itemContainer.setBorder(BorderFactory.createLineBorder(Color.black));
}
private void addItem(myObject item){
JComponent childPanel = myItem.getJComponent();
itemContainer.add(childPanel);
}
The items get added fine, but I want the JPanel to expand vertically to see them all when they overflow (and I'd prefer not to use a scollbar).
Any thoughts would be greatly appreciated!
Thanks,
Sam