Hi all,
I've bumped into an odd problem creating a GUI in swing. As you will see in the screenshots, I have a tabbed layout. Each tab is a Jpanel. On this panel I have put a JList, containing a series of objects. My intention is to have a single column of objects in the list, and have it to scroll when the objects exceed the vertical space.
My code is this:
[CODE=java]private JComponent createListBox() {
Object[] test = {"Thingy 1","Thingy 2",...};
JList list = new JList(test);
list.setLayoutO rientation(JLis t.VERTICAL_WRAP );
list.setSelecti onMode(ListSele ctionModel.SING LE_SELECTION);
list.setSize(38 5, 480);
list.setPreferr edSize(new Dimension(385, 480));
list.setVisible RowCount(-1);
list.setPreferr edSize(new Dimension(385,4 80));
JScrollPane listScroller = new JScrollPane(lis t);
return listScroller;
}[/CODE]
I know it should not be VERTICAL_WRAP, do read on.
When I use VERTICAL_WRAP I get this:

It's more than one column, I agree, but atleast it works.
When I use VERTICAL (which should be the option for what I intend to do) I get this:

My JList is squashed. It appears it doesn't take the set sizes into account.
I have little experience in creating GUI's, and I haven't found a solution. I hope you can help me.
Thanks.
The layoutManger on the pannel is a FlowLayout btw.
I've bumped into an odd problem creating a GUI in swing. As you will see in the screenshots, I have a tabbed layout. Each tab is a Jpanel. On this panel I have put a JList, containing a series of objects. My intention is to have a single column of objects in the list, and have it to scroll when the objects exceed the vertical space.
My code is this:
[CODE=java]private JComponent createListBox() {
Object[] test = {"Thingy 1","Thingy 2",...};
JList list = new JList(test);
list.setLayoutO rientation(JLis t.VERTICAL_WRAP );
list.setSelecti onMode(ListSele ctionModel.SING LE_SELECTION);
list.setSize(38 5, 480);
list.setPreferr edSize(new Dimension(385, 480));
list.setVisible RowCount(-1);
list.setPreferr edSize(new Dimension(385,4 80));
JScrollPane listScroller = new JScrollPane(lis t);
return listScroller;
}[/CODE]
I know it should not be VERTICAL_WRAP, do read on.
When I use VERTICAL_WRAP I get this:

It's more than one column, I agree, but atleast it works.
When I use VERTICAL (which should be the option for what I intend to do) I get this:

My JList is squashed. It appears it doesn't take the set sizes into account.
I have little experience in creating GUI's, and I haven't found a solution. I hope you can help me.
Thanks.
The layoutManger on the pannel is a FlowLayout btw.
Comment