Results 1 to 3 of 3
  1. #1
    bahumbaba is offline Member
    Join Date
    Dec 2009
    Rep Power

    Default Activate JComboBox 1 when object is selected in JComboBox 2...

    Hi forum

    I've looked around on the internet and even asked my programming teatcher, but either came out positive :)

    I need to activate a JComboBox, by having selected 1 element in a different JComboBox...

    Can anyone help me with this :confused:

  2. #2
    LittleRave is offline Member
    Join Date
    Dec 2009
    Rep Power


    one way that definitely works is using an observer pattern ;)
    let the box1 observe the box2 and when selecting the object in box2 send an information to box1 so it can activate itself
    or to the superior component the box is in or to whatever component that can activate your box1 ;)

    im sure there are more solutions and i dont know if this is the best one but its definitely a good one

    for info on how to implement and use the observer pattern try wiki ;)

  3. #3
    zweibieren is offline Senior Member
    Join Date
    Aug 2009
    Pittsburgh, PA
    Rep Power


    Let master be the initial combobox
    and slave be the one that appears when a certain item is selected in master.

    In the managing application, do

    Java Code:
    master.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            // check to see if this is the trigger item
            // if so, do this
                slave.setSelectedIndex(index of desired item);
    Relevant (but skimpy) tutorials: JComboBox ItemListener

Similar Threads

  1. Replies: 5
    Last Post: 04-25-2009, 08:00 PM
  2. JComboBox
    By pinks_70986 in forum New To Java
    Replies: 2
    Last Post: 02-19-2009, 05:26 PM
  3. JComboBox
    By Fosters in forum AWT / Swing
    Replies: 0
    Last Post: 08-10-2008, 01:22 PM
  4. Help with jComboBox
    By Marcus in forum AWT / Swing
    Replies: 2
    Last Post: 07-01-2007, 11:08 PM
  5. jcombobox
    By Freddie in forum AWT / Swing
    Replies: 4
    Last Post: 05-11-2007, 12:48 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