How can you get a JList to simple display a one word string.

I know the method of JList.setListData(Object[]);
I have an object[], but it is multiple lines of information and it looks weird in the list display.

How can I get an Object[] to simply display the first line of the array?

6 Years
Discussion Span
Last Post by charlieruns

You mean display only one element of the array?
You can create an array that has only one element, the element you want to display. But that would make the JList useless since that is not its purpose. Maybe you can change the way you add the JList to the frame, make it a bit wider.
Also if you look at the API there is an example on how to add scrolling to the list.

If you had already thought of that, sorry but that was my thought too.

Another thing would be to make a custom ListModel. Again check the API of the JList


Im not to sure I guess about the actual use of the JList.
It is scrollable now, but it just looks weird.

I looked up how to make the ListModel thing but I had trouble already incorporating that into what I had already made.

So as for now I guess I'll just keep it displaying the entire photo specs.

Thanks javaAddict.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.