There is a short example below - I added all of my properties too for each - just in case something I'm doing in JList is nullifing what I'm doing in JScrollPane or vice versa? Thanks in advance for any help!
JList jList1;
JScrollPane scrollPane = new JScrollPane(jList1);
listItems.add(..)
jList1 = new JList(listItems);
scrollPane.setBounds(38,117,120,114);
scrollPane.setAutoscrolls(true);
scrollPane.createVerticalScrollBar();
scrollPane.setWheelScrollingEnabled(true);
scrollPane.setNextFocusableComponent(jList1);
scrollPane.setEnabled(true);
jList1.setEnabled(true);
jList1.setAutoscrolls(true);
jList1.setDebugGraphicsOptions(0);
jList1.setDoubleBuffered(false);
jList1.setNextFocusableComponent(scrollPane);
jList1.setRequestFocusEnabled(true);
jList1.setFixedCellHeight(-1);
jList1.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
jList1.setBounds(new Rectangle(0, 0, 104, 114));
this.getContentPane().add(scrollPane, null);
scrollPane.add(jList1);
you have here many things which are unnecessary:
> scrollPane.setBounds(38,117,120,114);
this is job of LayoutManager
> scrollPane.createVerticalScrollBar();
no need at all (used by ScrollPaneUI implementations to create the vertical
scrollbar - you should override it if you want JScrollPane to use some
subclass of JScrollBar)
> scrollPane.setNextFocusableComponent(jList1);
???
> scrollPane.setEnabled(true);
enabled by default
> jList1.setEnabled(true);
enabled by default
> jList1.setDebugGraphicsOptions(0);
javadoc says: A value of 0 causes no changes to the debugging options.
> jList1.setDoubleBuffered(false);
why?
> jList1.setNextFocusableComponent(scrollPane);
???
> jList1.setRequestFocusEnabled(true);
this is default value
> jList1.setFixedCellHeight(-1);
this is default value
> jList1.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
this is default
> jList1.setBounds(new Rectangle(0, 0, 104, 114));
this is job of JScrollPane's LayoutManager
--
____________
http://reader.imagero.com the best java image reader.