Results 1 to 5 of 5
  1. #1
    logicbug's Avatar
    logicbug is offline Member
    Join Date
    Jan 2009
    Location
    The Great White North, eh?
    Posts
    76
    Rep Power
    0

    Default [SOLVED] JList( Vector ) Display problem

    I have a JList initialized with a vector of objects. I want the JList to display a specific variable from each object in question, but so far it displays the class name and some seemingly random letters and numbers.

    i.e. Object@d4g3s3

    I've been reading all morning and can't find an example for how to make it present a variable from the object instead.

    Can someone point me in the right direction?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    What is the toString() method for the objects in the arraylist (I think I already know the answer to this)?

  3. #3
    logicbug's Avatar
    logicbug is offline Member
    Join Date
    Jan 2009
    Location
    The Great White North, eh?
    Posts
    76
    Rep Power
    0

    Default

    Figured it out. Turns out JLists return the value of the objects toString Method. Just had to write one for my object.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    good deal. How did you figure this out? my post, or another forum?

  5. #5
    logicbug's Avatar
    logicbug is offline Member
    Join Date
    Jan 2009
    Location
    The Great White North, eh?
    Posts
    76
    Rep Power
    0

    Default

    A Sun SDN Article actually, looks like we were both typing our messages at the same time.

Similar Threads

  1. How do I display a JList with icons and text?
    By aneesahamedaa in forum AWT / Swing
    Replies: 2
    Last Post: 09-04-2008, 09:49 AM
  2. JList and records, what to do to solve the problem
    By willemjav in forum Java Applets
    Replies: 10
    Last Post: 06-11-2008, 03:28 PM
  3. Problem with JComboBox and Jlist
    By java_fun2007 in forum New To Java
    Replies: 2
    Last Post: 05-07-2008, 09:58 PM
  4. JList problem
    By zizou147 in forum Advanced Java
    Replies: 1
    Last Post: 04-17-2008, 09:50 AM
  5. Vector problem
    By Ace_Of_John in forum New To Java
    Replies: 1
    Last Post: 01-27-2008, 09:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •