JDK 5.0 Swing - JButton Duplicated Events
I have JPanel that implements Action Listener, then a few JButtons that receive an action listerner to (this). I noticed that evertime any button is clicked, the action associated to the button is repeated twice...
publicclass GenerateFileViewextends JPanelimplements ActionListener{
...
btnGenerate.addActionListener(this);
...
publicvoid actionPerformed(ActionEvent evt){
Object eventSource = evt.getSource();
if (eventSource.equals(cmbWorkOrder)){
...
}elseif (eventSource == btnGenerate){
if (this.validateFields()){
this.generateFile();
}
}
}
}
In this case the method of generateFile is invoked twice and as a result, my output file is generated the first time, and then is overwritten with a second write. Also the method validateFileds() displays dialogs for each invalid fields, and in that case also the dialogs are displayed twice.
The obvious answer was that I have added the action lister to the button twice, however that is not the case.
Any ideas/help on what I may be missing here ?
Thanks,
-MD.

