File Dialog opening twice?


2006-06-03 11:53:00 PM
jbuilder10
I've beggining with java and was trying jbuilder. When I am trying to
get the results of a file dialog box when I click the browse
button(button6) I get the dialog box and when I select the file or hit
cancel the dialog reopens again. When I select the second time I get
the results I'm looking for. Any ideas as to why this is happening?
Thanks
public void jButton6_actionPerformed(ActionEvent e) {
JFileChooser choose = new JFileChooser();
choose.addChoosableFileFilter(new ImageFilter());
choose.setAcceptAllFileFilterUsed(false);
choose.setVisible(true);
int returnVal = choose.showDialog(this, "Attach Image");
if (choose.getSelectedFile() != null) {
if (returnVal == JFileChooser.APPROVE_OPTION) {
jTextField6.setText(choose.getSelectedFile().getAbsolutePath());
}
}
}