Reputation: 1686
I have a jList in a ScrollPane and it behaves weird when I am resizing my frame. Normally it is like this: And after I grow the table on the left horizontally, my jList becomes like this:
I am posting some code of the gui which might be helpful:
scrlInterfaceList.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scrlInterfaceList.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
//---- list1 ----
lstInterfaces.setBorder(BorderFactory.createTitledBorder(LFwPolicyMaker.messages.getString("IpMacMatcher.MatchTab.controlPanel.interfaces.title")));
lstInterfaces.setPreferredSize(null);
lstInterfaces.setMaximumSize(new Dimension(55, 90));
lstInterfaces.setMinimumSize(new Dimension(55, 90));
lstInterfaces.setLayoutOrientation(JList.VERTICAL);
lstInterfaces.setModel(new AbstractListModel() {
String[] strings = getInterfaces();
public int getSize() {
return strings.length;
}
public Object getElementAt(int i) {
return strings[i];
}
});
scrlInterfaceList.setViewportView(lstInterfaces);
setSelectedInterfaces();
add(scrlInterfaceList,new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 0, 0), 0, 0));
What might be the problem? I want the jList to continue shrinking horizontally, like the combobox, buttons above
Upvotes: 0
Views: 434
Reputation: 347184
Try setting the weighty value of the GridBagConstraints to 1.0 for the scrollpane
Upvotes: 4