Results 1 to 3 of 3
  1. #1
    Soda is offline Member
    Join Date
    Dec 2007
    Posts
    15
    Rep Power
    0

    Default Is it possible to get and store items to a variable in a combo box?

    I need to get the selected item in a combo box then store it in a variable..... Is it possible?

    Can I get the text from an editable combo box then store it in a variable?



    Thnx much for the help

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    8

    Default

    Java Code:
            String[] items = { "item 1", "item 2", "item 3" };
            JComboBox combo = new JComboBox(items);
            combo.setEditable(true);
            combo.setSelectedIndex(1);
            String selectedItem = (String)combo.getSelectedItem();
            System.out.println(selectedItem.equals("item 2"));

  3. #3
    Soda is offline Member
    Join Date
    Dec 2007
    Posts
    15
    Rep Power
    0

Similar Threads

  1. Replies: 0
    Last Post: 01-04-2008, 09:34 AM
  2. Combo Box Event handling
    By smajidali26 in forum AWT / Swing
    Replies: 1
    Last Post: 11-29-2007, 05:57 PM
  3. Adding items to a jComboBox
    By tronovan in forum New To Java
    Replies: 0
    Last Post: 08-08-2007, 08:48 AM
  4. hyperlinks from menu items?
    By asterope118 in forum New To Java
    Replies: 1
    Last Post: 07-16-2007, 01:49 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
  •