Results 1 to 4 of 4
  1. #1
    Prajin's Avatar
    Prajin is offline Senior Member
    Join Date
    Jun 2010
    Location
    Ktm, Nepal
    Posts
    120
    Rep Power
    0

    Exclamation JCombo Box selection index?

    Hi,

    If I have JCombo Box with items like "ABC", "XYZ" and "ABC" at 1,2, and 3 index respectively. If I click any of them, then it is supposed to display the respective table.

    But if I Click "ABC" of 3rd index then combo box returns the index of first found item, and so table of 1st item. In this way, I'll never get table of "ABC" at 3rd index.

    I don't want to add id(which is unique) of each item to combo box so that each item would be unique.

    How to overcome this problem?

  2. #2
    Michael Dunn is offline Member
    Join Date
    Jul 2008
    Posts
    62
    Rep Power
    0

  3. #3
    Prajin's Avatar
    Prajin is offline Senior Member
    Join Date
    Jun 2010
    Location
    Ktm, Nepal
    Posts
    120
    Rep Power
    0

    Default

    Ok,
    I thought using as object might help me but I didn't had clear idea.
    After looking at example, it's better now. I hope it'll work.

    - Thanks

  4. #4
    mrp3rf3ct83 is offline Member
    Join Date
    Jul 2010
    Posts
    6
    Rep Power
    0

    Default

    Definitely use objects instead of indexes whenever possible. Use the builder design pattern to develop the code needed to open the respective table after clicking the combobox.

Similar Threads

  1. populate jtable from jtextboxes and jcombo
    By purejoker in forum AWT / Swing
    Replies: 4
    Last Post: 12-02-2010, 09:29 AM
  2. Netbeans, Editable JCombo and EventListener
    By mine0926 in forum NetBeans
    Replies: 0
    Last Post: 07-10-2010, 03:55 AM
  3. jcombo in jtable
    By anilkumar_vist in forum Advanced Java
    Replies: 0
    Last Post: 12-12-2009, 06:47 AM
  4. Sort jcombo in jtable
    By anilkumar_vist in forum Advanced Java
    Replies: 1
    Last Post: 12-11-2009, 05:23 PM
  5. Display items in the JCombo Box
    By eddy001 in forum AWT / Swing
    Replies: 1
    Last Post: 01-21-2008, 12:27 AM

Posting Permissions

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