if (directory != null) {
myDirectory.setText(directory.getPath());
}
myDirectory.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
protected void textChanged(final DocumentEvent e) {
myDirectory.getTextField().setForeground(getDirectory() != null ? SimpleTextAttributes.REGULAR_ATTRIBUTES.getFgColor() :SimpleTextAttributes.ERROR_ATTRIBUTES.getFgColor());
updateOkButton();
}
});
if (extensions.size() == 0) {
myExtension.setEnabled(false);
}
else {
for (String extension : extensions) {
myExtension.addItem(extension);
}
}
if (defaultFileName != null) myFileName.setText(defaultFileName);
myFileName.getDocument().addDocumentListener(new DocumentAdapter() {
protected void textChanged(final DocumentEvent e) {
myFileName.setForeground(isValidFileName(myFileName.getText()) ? SimpleTextAttributes.REGULAR_ATTRIBUTES.getFgColor() :SimpleTextAttributes.ERROR_ATTRIBUTES.getFgColor());
updateOkButton();
}