0

i want to implement and open new window when i choose one entry from drop down list. However when I use getSelectedItem in if / else - it compile but returning errors when want to choose entry in application. Where is the problem ?

public class TemplatesList extends JComboBox<String>
{
    public String[] lista = {"change request", "emergancy change request", "problem request","problem handover", "Major Incident handover" };
    public JComboBox faceCombo;
    String e;


    public TemplatesList()
    {
        //faceCombo = new JComboBox();
        for (int i=0; i < lista.length; i++)
        {
            this.addItem(lista[i]);
        }
        addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
            if (faceCombo.getSelectedItem() == "change request"){
                SecondWindow regFace = new SecondWindow();
                regFace.setVisible(true);
            } else {

            }
        }
    });
    }
}
Ankit
  • 6,554
  • 6
  • 49
  • 71

1 Answers1

0

you can add item listener here and then check for selected item, depends on that you can make visible your panel or show dialog box.