I'm trying to get the input of several JComboBoxes and execute a statement depending on which option the user chose for example if destination combo Box = japan duration combo box = 10 days and hotel combox = hotel then print line "welcome" I have tried many options but not getting the desired outcome. at the moment I'm using an if statement with only 2 of 3 of the J combo boxes but it's not working here's my code:
any help?String[] Dest = new String[] {"Select Destination","Crete", "Paris", "Croatia"}; String[] Accomodation = new String[] {"Select your Accomodation","Hotel", "Villa", "Bed in Breakfast","Youth Hostel"}; JComboBox<String> comboDest1 = new JComboBox<String>(Dest); JComboBox<String> comboAccom1 = new JComboBox<String>(Accomodation); comboDest1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { // // Get the source of the component, which is our combo // box. // JComboBox comboDest1 = (JComboBox) event.getSource(); JComboBox comboAccom1 =(JComboBox) event.getSource(); Object selected = comboDest1.getSelectedItem(); Object selectedForAccom1 = comboAccom1.getSelectedItem(); if(comboDest1.getSelectedItem().equals("Crete") && comboAccom1.getSelectedItem().equals("Hotel")) { System.out.println("hey"); } } });