The Artima Developer Community
Sponsored Link

Java Answers Forum
JList

4 replies on 1 page. Most recent reply: May 26, 2003 10:36 AM by displace

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 4 replies on 1 page
displace

Posts: 6
Nickname: displace
Registered: May, 2003

JList Posted: May 25, 2003 12:52 PM
Reply to this message Reply
Advertisement
when i display array into a JList, it will give me funny characters.
jl = new JList(array);
can someone help me?
thanks.


zenykx

Posts: 69
Nickname: zenykx
Registered: May, 2003

Re: JList Posted: May 25, 2003 1:37 PM
Reply to this message Reply
Be a little more specific: what is contained in the array ?

---
There are only solutions !
-o- zenykx -o-

Joe Cole

Posts: 3
Nickname: joecole
Registered: May, 2003

Re: JList Posted: May 25, 2003 5:19 PM
Reply to this message Reply
You have obviously put some object into the array which does not have its toString() method overridden.

To change this overrirde the toString method

public String toString(){
return new String("Name:"+ name + " somethingelse " + somehtingelse);
}

The funny characters you see are the object@instance names. You can see how this is done in the source of object.java

Or, you could create a new listcellrenderer which determines how to show it, but thats harder.

See ListCellRenderer if you want to do this.

displace

Posts: 6
Nickname: displace
Registered: May, 2003

Re: JList Posted: May 26, 2003 9:16 AM
Reply to this message Reply
yes, it displays object@..... so how am i going to display the contents in a JList?
thanks.

displace

Posts: 6
Nickname: displace
Registered: May, 2003

Re: JList Posted: May 26, 2003 10:36 AM
Reply to this message Reply
oh... i got the contents already but how to arrange the data (align it properly)?

Flat View: This topic has 4 replies on 1 page
Topic: yahoo wont let me play Previous Topic   Next Topic Topic: Converting applet into standalone application

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use