Results 1 to 5 of 5
  1. #1
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,075
    Rep Power
    8

    Default short question about JComboBox

    Is there a method that returns only the index of
    the select item?

  2. #2
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default Re: short question about JComboBox

    Come on.
    That's what the API is for, not a forum like this.
    JComboBox (Java Platform SE 7 )
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,075
    Rep Power
    8

    Default Re: short question about JComboBox

    of course I first see (always) the API, tolls
    but there is no method that says index x is selected!

    getSelectedIndex() Returns the first item in the list that matches the given item.
    getSelectedItem() Returns the current selected item.

    The last would work for my, sure but than I have to use (String) and compare.....
    An index number of the selection would be much easier for my to work with?

  4. #4
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default Re: short question about JComboBox

    getSelectedIndex is the index of the selected item in the underlying list.
    It returns:
    "
    an integer specifying the currently selected list item, where 0 specifies the first item in the list; or -1 if no item is selected or if the currently selected item is not in the list
    "
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,075
    Rep Power
    8

    Default Re: short question about JComboBox

    okay you won, I should read the api better!
    thanks

Similar Threads

  1. Question in JCombobox
    By Walaa in forum AWT / Swing
    Replies: 9
    Last Post: 11-10-2012, 09:21 PM
  2. Replies: 3
    Last Post: 02-20-2011, 12:15 PM
  3. Replies: 2
    Last Post: 12-10-2009, 01:58 PM
  4. JComboBox Question
    By crazydeo in forum New To Java
    Replies: 1
    Last Post: 11-06-2008, 12:09 PM
  5. Short-cut key
    By tskumarme in forum New To Java
    Replies: 2
    Last Post: 05-28-2008, 04:16 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
  •