JFileChooser disable acept button
Im using JFileChooser (a sub class of it actually) and have a situation where I must ensure that pick an existing file.
My thoughts were that I could either
1. not allow users to type their own file name into the file box
or
2. do not allow them to choose the accept button when the files does not exist.
Exploring these ideas:
for #1 you could change the text box to be read only (not accept typing) at all times
for #2 you would have to change the accept button to read only if the file did not exist
playing with # 2, I changed the propertyChange listener
if ("SelectedFileChangedProperty".equals(evt.getPropertyName())){
if (!getSelectedFile().exists()){
// this is where you would disable the button
}
}
Does anyone have a cluehow you would go about disabling either the accept button or the text field?

