Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

limiting # of JList rows in a JScrollPane  RSS feed

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,
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!