Why does TextFieldWithBrowseButton open the file selection dialog twice?

I have forum I created with the GUI designer that includes a TextFieldWithBrowseButton. I used the code below to set it up, but when I hit the button, the file selection dialog appears twice. I tried removing the call to addBrowseFolderListener too see if it was also set up somewhere else, but then it the dialog didn't appear at all.

Is there something else I need to do?

private TextFieldWithBrowseButton changeLogFile;

...

final FileChooserDescriptor fileChooser =
FileChooserDescriptorFactory.createSingleLocalFileDescriptor();
String currentChangeLogFile =
LiquibaseProjectComponent.getInstance().getChangeLogFile();
if (currentChangeLogFile != null) {
changeLogFile.setText(currentChangeLogFile);
}
changeLogFile.setTextFieldPreferredWidth(100);
changeLogFile.addBrowseFolderListener("Select Change Log File", null, project,
fileChooser);

2 comments

Strange, I use ComboboxWithBrowseButton and the file chooser is opened only once after pressing "...".
Did you make sure, that addBrowseFolderListener is called only once? The code looks like something that could be called multiple times on an instance of the class that contains the code.

Cheers,
Robert

0

You were right. It was in the getComponent method of a wizard Step implementation and that method got called twice by the intellij API. I was able to see that by setting a break point on that line.

I moved the code to a different location and it works fine.

Thanks a lot,
Nathan

0

Please sign in to leave a comment.