Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2009
    Rep Power

    Default Sort jcombo in jtable

    Hello everyone, i want to create a JComboBox where i can write a letter
    and the comboBox show the elements starting with that letter, i mean,
    make a filter. For example if i got {"Air", "Home", "Homer"} y the
    comboBox, and i write in the comboBox the letter 'a', the combo show
    only the elements starting with that letter, it will show "Air", and if
    i only write the letter 'H', will show {"Home", "Homer"},

    Its just like a filter for the input, i hope you understand what i
    want. I'll be waiting for your answers. Thanks.
    Last edited by anilkumar_vist; 12-10-2009 at 11:31 AM.

  2. #2
    Supamagier is offline Senior Member
    Join Date
    Aug 2008
    Rep Power


    Keep all the items in your combobox in a String array(list) and check it every time you type something (using a keylistener)
    Java Code:
    for (String item : allItems) 
        if (item.startsWith(letter))
    something like this
    I die a little on the inside...
    Every time I get shot.

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. Sort and filter in Jtable (java ver 1.5 )
    By itaipee in forum AWT / Swing
    Replies: 3
    Last Post: 04-16-2009, 12:03 PM
  3. How to sort a JTable for multiple columns?
    By BLR in forum Advanced Java
    Replies: 2
    Last Post: 03-16-2009, 10:41 AM
  4. How to sort column in JTable
    By johnt in forum AWT / Swing
    Replies: 3
    Last Post: 06-14-2008, 05:48 AM
  5. sort columns in jtable
    By Alan in forum AWT / Swing
    Replies: 2
    Last Post: 05-14-2007, 05:18 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