passing parameters to Event Handler
Is there a way to do that? I really need to be able to call a method from a windowListener's event handler, but that method has 3 strings as parameters and throws IOException. Here's the code, but it's pretty self explanetory...
public RunMethodTesting(JFrame frame){
frame.addWindowListener(this);
progressBar =new JProgressBar(0, 100);
progressBar.setValue(0);
progressBar.setStringPainted(true);
JPanel panel =new JPanel();
panel.add(progressBar);
add(panel, BorderLayout.PAGE_START);
}
publicvoid propertyChange(PropertyChangeEvent evt){
if ("progress" == evt.getPropertyName()){
int progress = (Integer) evt.getNewValue();
progressBar.setValue(progress);
}
}
publicstaticvoid createAndShowBarGUI(String filenamed, String file2named, String savedFile)throws IOException{
//Create and set up the window.
JFrame frame =new JFrame("Progress Bar");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Create and set up the content pane.
JComponent newContentPane =new RunMethodTesting(frame);
newContentPane.setOpaque(true);//content panes must be opaque
frame.setContentPane(newContentPane);
filenamed = filenamed;
file2named = file2named;
savedFile = savedFile;
//Display the window.
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
publicvoid windowActivated(WindowEvent we){
action(filenamed, file2named, savedFile);
}
publicvoid windowDeactivated(WindowEvent we){}
publicvoid windowClosed(WindowEvent we){}
publicvoid windowDeiconified(WindowEvent we){}
publicvoid windowIconified(WindowEvent we){}
publicvoid windowClosing(WindowEvent we){}
publicvoid windowOpening(WindowEvent we){}
publicvoid windowOpened(WindowEvent we){}
publicvoid action(String filenamed, String file2named, String savedFile)throws IOException{
Task task =new Task();
task.addPropertyChangeListener(this);
task.runMethod(filenamed, file2named, savedFile);
}
createAndShowBarGUI() gets called first.
Thanks

