I wrote code that creates a JComboBox with three options and is supposed to open a new JFrame when one is selected, but nothing happens. Where have I gone wrong?
JComboBox comboBox = new JComboBox();
comboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
JComboBox comboBox = (JComboBox) arg0.getSource();
Object newItem = comboBox.getSelectedItem();
boolean same = newItem.equals(oldItem);
oldItem = newItem;
if (" Loan".equals(arg0.getActionCommand())){
Loan loan = new Loan();
loan.setVisible(true);
frame.setVisible(false);
}
else if (" Return".equals(arg0.getActionCommand())){
//Code to open new jframe.
}
else if (" Renew".equals(arg0.getActionCommand())){
//Code to open new jframe.
}
}
});