Monday, March 23, 2009

How do I add scroll bars to my JList?

You need to add your JList (or any component) to a JScrollPane. Easiest way to do this is to pass your component to the JScrollPane’s constructor. You then add the JScrollPane to your component hierarchy (instead of adding your JList).


JScrollPane scrollPne = new JScrollPane(mylist);
panel.add(scrollPane);

No comments: