JComboBox ActionPerformed performing twice
I have a combo box that when a user selects a value, the actionListener (actionPerform) is called twice. The code creates a new jFrame with a table but because it is called twice, I get 2 screens and I need only one. I tried using an ItemListener and get the same results of the ItemStateChange being called twice. Below is my code.
private JComboBox getFleetCmbBox(){
if (fleetCmbBox ==null){
FleetComboListModel model =new FleetComboListModel(fleet);
fleetCmbBox =new JComboBox(model);
fleetCmbBox.setSelectedIndex(0);
fleetCmbBox.addActionListener(fleetActionListener);
//fleetCmbBox.addItemListener(itemListener);
}
return fleetCmbBox;
}
ActionListener fleetActionListener =new ActionListener(){
publicvoid actionPerformed(ActionEvent event){
if ("comboBoxChanged".equals(event.getActionCommand())){
System.out.println("fleet manager action performed");
selFleetMgr = fleet[getFleetCmbBox().getSelectedIndex()];
OpAlertsTable table =new OpAlertsTable(selFleetMgr);
table.pack();
table.setVisible(true);
}
}
};

