File Dialog opening twice?

B

Barkster

I'm begining with java and was trying Borlan 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());
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top