• Post Reply Bookmark Topic Watch Topic
  • New Topic

JList  RSS feed

 
Swaminathan Ramanathan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everyone ,
I wanted to declare a JList Box and add some items to it. Thats fine. Now my problem is when i wanted to make multiselection impossible and to display only three items by default , it doesnot work.

public void setVisibleRowCount(int visibleRowCount)
public void setSelectionMode(int selectionMode)
I tried the above methods but could not solve the prob. I want the exact usage of these two methods.
Thanks
Swamy
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This should work -
JList myList = new Jlist(myInput);
myList.setselectionMode(SINGLE_SELECTION);
myList.setVisibleRowCount(3);
The int value SINGLE_SELECTION is defined int the interface ListSelectionModel.
If this is not working can you show the error??
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!