File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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!