Closed Thread
Results 1 to 2 of 2

Thread: Coding a ComboBox to change contents of a separate ComboBox

  1. #1
    Auxcil's Avatar
    Auxcil is offline Newbie
    Join Date
    Mar 2010
    Location
    Illinois, USA
    Posts
    23
    Blog Entries
    1
    Rep Power
    0

    Post Coding a ComboBox to change contents of a separate ComboBox

    I am currently using NetBeans to try and code some simple applications that could be used for gaming and to freshen up on what I learned. Currently I am trying to get a Race ComboBox to change what is modeled by the Class ComboBox. It doesn't seem like it is too hard to write by hand, but I am trying to find out how to do it with NetBeans Visual JFrame.

    Any help is appreciated.

    Code:
    class ClassListener implements ActionListener
            {
                public void actionPerformed(ActionEvent event)
                {
                    if (raceCombo.getSelectedItem().equals("Ursidus"))
                    {
                        classCombo.removeAllItems() ;
                        classCombo.addItem("Brawler") ;
                        classCombo.addItem("Shaman") ;
                    }
                    else if (raceCombo.getSelectedItem().equals("Sapian"))
                    {
                        classCombo.removeAllItems() ;
                        classCombo.addItem("Warrior") ;
                        classCombo.addItem("Tamer") ;
                    }
                    else if (raceCombo.getSelectedItem().equals("Neronaga"))
                    {
                        classCombo.removeAllItems() ;
                        classCombo.addItem("Assassin") ;
                        classCombo.addItem("Corrupter") ;
                    }
                    else if (raceCombo.getSelectedItem().equals("Avian"))
                    {
                        classCombo.removeAllItems() ;
                        classCombo.addItem("Ranger") ;
                        classCombo.addItem("Purified") ;
                    }
                    else if (raceCombo.getSelectedItem().equals("Aqvita"))
                    {
                        classCombo.removeAllItems() ;
                        classCombo.addItem("Summoner") ;
                        classCombo.addItem("Oracle") ;
                    } 
                    else if (raceCombo.getSelectedItem().equals("Feleos"))
                    {
                        classCombo.removeAllItems() ;
                        classCombo.addItem("Duelist") ;
                        classCombo.addItem("Cleric") ;
                    }
                    else if (raceCombo.getSelectedItem().equals("Parrus"))
                    {
                        classCombo.removeAllItems() ;
                        classCombo.addItem("Scratch") ;
                        classCombo.addItem("Mancer") ;
                    }
                    else if (raceCombo.getSelectedItem().equals("Canos"))
                    {
                        classCombo.removeAllItems() ;
                        classCombo.addItem("Hunter") ;
                        classCombo.addItem("Wernos") ;
                    }
                    raceCombo.addActionListener(this) ;
                }
            }
    Last edited by ZekeDragon; 03-16-2010 at 05:01 PM. Reason: Please remember to use [code] tags when posting code.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Auxcil's Avatar
    Auxcil is offline Newbie
    Join Date
    Mar 2010
    Location
    Illinois, USA
    Posts
    23
    Blog Entries
    1
    Rep Power
    0

    Re: Coding a ComboBox to change contents of a separate ComboBox

    Allright, this can be closed.

    Biggest problem was I was trying to use an ActionListener and I needed an ItemListener

    along with a few other bugs in code I didn't post.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Combobox Hell
    By jkjavedpro in forum C# Programming
    Replies: 4
    Last Post: 08-27-2010, 09:01 AM
  2. Replies: 0
    Last Post: 07-02-2010, 01:43 PM
  3. ComboBox with CheckBoxes ..
    By Jordan-Girl in forum C# Programming
    Replies: 1
    Last Post: 07-14-2008, 03:56 PM
  4. help on combobox
    By Gz1987 in forum Visual Basic Programming
    Replies: 4
    Last Post: 03-29-2008, 05:41 PM
  5. getText from ComboBox
    By WingKalimdor in forum Java Help
    Replies: 2
    Last Post: 01-09-2008, 07:21 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts