Results 1 to 3 of 3
  1. #1
    bhaskaranbe is offline Member
    Join Date
    Jun 2015
    Posts
    7
    Rep Power
    0

    Default How do I populate the second combobox when I make a selection in the first combobox

    example: {Ananth=[English, Maths], Karan=[Computer Science, Physics]}

    First combo box should display name: Ananth and karan

    if first combo box select value as "Ananth" the second combobox should display the values "English, Maths"
    if first combo box select value as "Karan" the second combobox should display the values "Computer Science, Physics"

    The first combobox i did:

    ComboBox <String> student=new ComboBox<String>();
    student.getItems().addAll(map.keySet());

    please let me know the logic or code for doing 2nd combox box.

    Thanks,
    Bhaskaran

  2. #2
    Artemia is offline Member
    Join Date
    May 2015
    Location
    Netherlands
    Posts
    39
    Rep Power
    0

    Default Re: How do I populate the second combobox when I make a selection in the first combob

    if you have the values for the second ComboBox in an array (English, Math)
    use the appropriate listener (ItemListener I think) to load that array into the second ComboBox.

    I've only ever tried loading a new value into a TextField depending on the selection in the ComboBox, but I think it should work the same for a second ComboBox.
    Last edited by Artemia; 06-22-2015 at 08:19 AM.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: How do I populate the second combobox when I make a selection in the first combob

    There's already one thread about this. Please see the second paragraph of the Forum rules: Forum Rules

    Also, in the other thread you mentioned JavaFX; here you mention only a combo box, which could easily be Swing.

    db

    THREAD CLOSED
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Problem: Fill a comboBox from another combobox
    By Ridha in forum AWT / Swing
    Replies: 2
    Last Post: 03-08-2013, 02:34 PM
  2. Adding null selection to a Combobox
    By fatabass in forum AWT / Swing
    Replies: 4
    Last Post: 03-31-2012, 01:10 AM
  3. Table filtering base on selection in a combobox
    By new2java2009 in forum New To Java
    Replies: 10
    Last Post: 04-27-2011, 10:20 PM
  4. Replies: 6
    Last Post: 05-19-2010, 12:26 AM
  5. Replies: 2
    Last Post: 04-28-2009, 04:52 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
  •