newbie here.
So, I´m trying to list a few items with the Jlist, but I can´t wrap these to the next line like I do it with a jTextArea. When I put a long string for a list item, the window width enlarges with it. That is not desirable.
I, then, restricted the width of the list. It worked, but then you can´t read the text.
jList1.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "Item 1", "Item 2 is a big old thing and it won´t wrap", "Item 3" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
The above code returns:
+---------------+
|Item 1 |
|Item 2 is a b..|
|Item 3 |
+---------------+
But I wanted:
+---------------+
|Item 1 |
|Item 2 is a big|
|old thing and i|
|t won´t wrap |
|Item 3 |
+---------------+
The reason I want it is to be able to select a line individually even if I don´t know where each item starts.
Someone told me of putting a horizontal scroll bar and that seems nice. I just don´t know how to go about it.
Thanks for the input!