K
Kurt M Peters
I am having a problem getting a JList to scroll.
I am using an extension of AbstractListModel at a model in a JList:
public class TreeSetListModel extends AbstractListModel {
private Set<String> treeSetList;
/** Creates a new instance of TreeSetListModel */
public TreeSetListModel(Set<String> inSet) {
treeSetList = inSet;
}
....
}
For the life of me, I cannot get the vertical scrollbar to scroll. The
horizontal one does (which actually is useless). Does anyone have any ideas
what I'm going wrong? Please see comments and code handling the guilty
objects below:
jSPListNodes = new JScrollPane(JListNodes);
JListNodes = new javax.swing.JList();
jSPListNodes = new JScrollPane(JListNodes);
jSPListNodes.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
jSPListNodes.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
jSPListNodes.setAutoscrolls(true);
jSPListNodes.setMaximumSize(new java.awt.Dimension(48, 48));
jSPListNodes.setPreferredSize(new java.awt.Dimension(48, 48));
jSPListNodes.setViewportView(JListNodes);
jPNodeComponentSelections.add(jSPListNodes,
java.awt.BorderLayout.WEST);
JListNodes.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
JListNodes.setFixedCellHeight(48);
JListNodes.setMaximumSize(new java.awt.Dimension(264, 264));
JListNodes.setMinimumSize(new java.awt.Dimension(52, 70));
JListNodes.setPreferredSize(new java.awt.Dimension(52, 80));
JListNodes.setVisibleRowCount(2);
// after creating and filling a TreeSet, I put it in the List
JListNodes.setModel(new TreeSetListModel(nodeSet));
//I even tried to revalidate, which doesn't seem to work:
JListNodes.revalidate();
jPNodeComponentSelections.revalidate();
jSPListNodes.revalidate();
Thanks in advance,
Kurt
I am using an extension of AbstractListModel at a model in a JList:
public class TreeSetListModel extends AbstractListModel {
private Set<String> treeSetList;
/** Creates a new instance of TreeSetListModel */
public TreeSetListModel(Set<String> inSet) {
treeSetList = inSet;
}
....
}
For the life of me, I cannot get the vertical scrollbar to scroll. The
horizontal one does (which actually is useless). Does anyone have any ideas
what I'm going wrong? Please see comments and code handling the guilty
objects below:
jSPListNodes = new JScrollPane(JListNodes);
JListNodes = new javax.swing.JList();
jSPListNodes = new JScrollPane(JListNodes);
jSPListNodes.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
jSPListNodes.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
jSPListNodes.setAutoscrolls(true);
jSPListNodes.setMaximumSize(new java.awt.Dimension(48, 48));
jSPListNodes.setPreferredSize(new java.awt.Dimension(48, 48));
jSPListNodes.setViewportView(JListNodes);
jPNodeComponentSelections.add(jSPListNodes,
java.awt.BorderLayout.WEST);
JListNodes.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
JListNodes.setFixedCellHeight(48);
JListNodes.setMaximumSize(new java.awt.Dimension(264, 264));
JListNodes.setMinimumSize(new java.awt.Dimension(52, 70));
JListNodes.setPreferredSize(new java.awt.Dimension(52, 80));
JListNodes.setVisibleRowCount(2);
// after creating and filling a TreeSet, I put it in the List
JListNodes.setModel(new TreeSetListModel(nodeSet));
//I even tried to revalidate, which doesn't seem to work:
JListNodes.revalidate();
jPNodeComponentSelections.revalidate();
jSPListNodes.revalidate();
Thanks in advance,
Kurt