Results 1 to 2 of 2
  1. #1
    MaxMonic is offline Member
    Join Date
    Dec 2010
    Posts
    4
    Rep Power
    0

    Default Get the item in JComboBox

    Hi.

    I have a JComboBox called comboBox in gui.java.

    Is it possible for to query the current selected item of the comboBox within another file.java ?

    If so, how should I code it?

  2. #2
    MaxMonic is offline Member
    Join Date
    Dec 2010
    Posts
    4
    Rep Power
    0

    Default

    I already solved the issue.
    I created a String powerState to save the value of newItem (value from combo box).

    Then i just access the static field normally using Gui.powerState .

    Java Code:
        
    private void jcb_powerOffActionPerformed(java.awt.event.ActionEvent evt) {                                             
            JComboBox cb = (JComboBox)evt.getSource();
            String newItem = cb.getSelectedItem().toString();
            powerState=newItem;
        }

Similar Threads

  1. Getting an item from an array
    By ile4 in forum New To Java
    Replies: 9
    Last Post: 01-13-2011, 04:42 PM
  2. Selecting last item from a Jcombobox wont work
    By cotarelo in forum AWT / Swing
    Replies: 1
    Last Post: 07-14-2010, 12:30 AM
  3. Replies: 2
    Last Post: 12-10-2009, 02:58 PM
  4. Creating multiline item in JComboBox
    By javabud in forum AWT / Swing
    Replies: 2
    Last Post: 07-17-2009, 04:50 PM
  5. [SOLVED] Item too big for JComboBox
    By nwboy74 in forum AWT / Swing
    Replies: 5
    Last Post: 02-23-2009, 09:21 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
  •