How do you add a JList to a JScrollPane ?
Asked
Active
Viewed 5.5k times
17
-
1[Here is how to add scroll bar to list][1] [1]: http://stackoverflow.com/questions/940838/adding-scrollbar-to-jlist – David Mathias Mar 20 '13 at 11:57
-
Read the section from the Swing tutorial on [How to Use Lists](http://docs.oracle.com/javase/tutorial/uiswing/components/list.html) for a working example. That is start with the tutorials for the basics, not the forum. – camickr Mar 20 '13 at 15:11
1 Answers
30
Put your JList
in a JScrollPane
JScrollPane scrollPane = new JScrollPane();
JList list = new JList();
scrollPane.setViewportView(list);

Apurv
- 3,723
- 3
- 30
- 51
-
-
first I opened my design page(JFrame) then ı added JScrollPane on it I put Jlist they both in the same size but nothing has changed:( – hiii Mar 20 '13 at 12:01
-
@hiii It sounds like you are getting confused with a visual form designer. What IDE are you using? – Duncan Jones Mar 20 '13 at 12:03