File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes horizontal JList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "horizontal JList" Watch "horizontal JList" New topic

horizontal JList

Kate Zoy
Ranch Hand

Joined: Feb 11, 2004
Posts: 33
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?!
Carlos Failde
Ranch Hand

Joined: Oct 20, 2000
Posts: 84
Try this
I agree. Here's the link:
subject: horizontal JList
It's not a secret anymore!