Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

limiting # of JList rows in a JScrollPane

Kevin Adams
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to limit the number of rows that my JList inside a JScrollPane shows... I only want it to display 5 Rows at a time.
Here's a snippet of my code:
String Components[] = {"Component 1","Component 2","Component 3",
"Component 4","Component 5","Component 6","Component 7"};
JList list = new JList(Components);
JScrollPane scrollPane;
scrollPane = new JScrollPane(list);
The scrollPane is contained within a panel that has a layout of BoxLayout.Y_AXIS.
For some reason it displays more rows.
Does anybody have any advice?
Thanks in advance,
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic