Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

horizontal JList

 
Kate Zoy
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some code that I thought would work to make an horizontal JList, but it doesn't.
listModel = new DefaultListModel();
someButton.addActionListener( new ActionListener(){
public void actionPerformed( ActionEvent ae ){
listModel.addElement( //i got some string in here );}});
list = new JList( listModel );
list.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
list.setLayoutOrientation( JList.HORIZONTAL_WRAP );
JScrollPane scroll = new JScrollPane( list );
panel.add( scroll );
So with this code, I get a little dot of a list and it never adds the items that are to be added in the list. When I remove the scroll, then it works fine, but still not horizontal. Anyone knows how to make this thing go horizontal?!
Thx!!!
 
Carlos Failde
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic