This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JList question? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JList question?" Watch "JList question?" New topic

JList question?

Dominic Steng�rd
Ranch Hand

Joined: Feb 05, 2001
Posts: 186
Hey JavaGuys!

Got a really annoying problem;
Ive got a JList which I want to add strings to. When I add one string everything works fine but when I want to add two or more strings nothing shows up in the JList. The code for adding the strings is:


Never had this problem with JLists before ... any thoughts are welcome.
Thanks in advance.

Dominic Steng�rd<br />Sun Certified Java 2 Programmer
Matthew Taylor

Joined: Jun 13, 2004
Posts: 110
I had some similar problems using Strings in JLists, so I wrote a class that only uses Strings with JLists that extends JList:

I guess I should have commented it, but the method names are self-explanitory. There are methods for adding Strings to the JList that allow repeat values or that don't allow them. This code works, but I don't know how efficiently.
[ October 18, 2004: Message edited by: Matthew Taylor ]

Grails Consultant
I agree. Here's the link:
subject: JList question?
It's not a secret anymore!