Hi :)
I want to disable autoscrolling of my JList. So that when the user selects an item in the list, and moves the cursor outside the window, while still holding the button pressed, the list shouldn't scroll. I use the setAutoscrolls(false) method but with no success. Any help is much appreciated. Here is the code:
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JScrollPane;
public class Main {
private static final String[] ITEMS = new String[] {"1",
"2","3","4","5","6","7","8","9","10","11",
"12","13","14","15","16","17","18","19","20","21",
"22","23","24","25","26","27","28","29","30"};
public static void main(String[] args) {
JFrame f = new JFrame();
JList list = new JList(ITEMS);
list.setAutoscrolls(false);
JScrollPane scrollPane = new JScrollPane(list);
f.add(scrollPane);
f.setPreferredSize(new Dimension(200, 200));
f.pack();
f.setVisible(true);
}
}
Kind regards,
/Patrik