-
Bug
-
Resolution: Fixed
-
P4
-
8, 11, 17, 18, 19
-
b10
-
x86_64
-
windows_10
ADDITIONAL SYSTEM INFORMATION :
Java version is 1.8.0_311, L&F used is Nimbus
A DESCRIPTION OF THE PROBLEM :
JFileChooser is created with selection mode DIRECTORIES_ONLY.
When there is a symlink created by "mklink /D link target", this visually appears as a directory in JFileChooser but cannot by selected while normal directory can. By cannot be selected I don't mean it cannot be clicked by mouse or navigated to by arrow keys, but the PropertyChangeEvent for JFileChooser.SELECTED_FILE_CHANGED_PROPERTY reports the newValue to be null and also the Folder name: text field does not change to reflect the path of the selected symlink.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a regular directory in windows: mkdir c:\target
2. Create a link targeting this directory: mklink /D c:\link c:\target
3. In JFileChooser, navigate to c:\
4. observe that when you click on target, the newValue of the property correctly reports "c:\target"
5. click on link directory and see that the newValue reports null
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
newValue = "c:\link"
ACTUAL -
newValue = null
---------- BEGIN SOURCE ----------
import java.awt.Dimension;
import java.awt.EventQueue;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Arrays;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.WindowConstants;
public class FileChooserTest {
public static void main(String[] args) {
Arrays.stream(UIManager.getInstalledLookAndFeels()).filter(info -> "Nimbus".equals(info.getName())).findFirst().ifPresent(info -> {
try {
UIManager.setLookAndFeel(info.getClassName());
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
//
}
});
JFrame frame = new JFrame("JFileChooser test");
frame.setPreferredSize(new Dimension(600, 600));
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
JFileChooser jfc = new JFileChooser();
jfc.setDialogType(JFileChooser.CUSTOM_DIALOG);
jfc.setControlButtonsAreShown(false);
jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
jfc.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(evt.getPropertyName())) {
System.out.println(String.format("Value changed: %s -> %s", evt.getOldValue(), evt.getNewValue()));
}
}
});
frame.add(jfc);
frame.pack();
EventQueue.invokeLater(() -> frame.setVisible(true));
}
}
---------- END SOURCE ----------
Java version is 1.8.0_311, L&F used is Nimbus
A DESCRIPTION OF THE PROBLEM :
JFileChooser is created with selection mode DIRECTORIES_ONLY.
When there is a symlink created by "mklink /D link target", this visually appears as a directory in JFileChooser but cannot by selected while normal directory can. By cannot be selected I don't mean it cannot be clicked by mouse or navigated to by arrow keys, but the PropertyChangeEvent for JFileChooser.SELECTED_FILE_CHANGED_PROPERTY reports the newValue to be null and also the Folder name: text field does not change to reflect the path of the selected symlink.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a regular directory in windows: mkdir c:\target
2. Create a link targeting this directory: mklink /D c:\link c:\target
3. In JFileChooser, navigate to c:\
4. observe that when you click on target, the newValue of the property correctly reports "c:\target"
5. click on link directory and see that the newValue reports null
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
newValue = "c:\link"
ACTUAL -
newValue = null
---------- BEGIN SOURCE ----------
import java.awt.Dimension;
import java.awt.EventQueue;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Arrays;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.WindowConstants;
public class FileChooserTest {
public static void main(String[] args) {
Arrays.stream(UIManager.getInstalledLookAndFeels()).filter(info -> "Nimbus".equals(info.getName())).findFirst().ifPresent(info -> {
try {
UIManager.setLookAndFeel(info.getClassName());
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
//
}
});
JFrame frame = new JFrame("JFileChooser test");
frame.setPreferredSize(new Dimension(600, 600));
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
JFileChooser jfc = new JFileChooser();
jfc.setDialogType(JFileChooser.CUSTOM_DIALOG);
jfc.setControlButtonsAreShown(false);
jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
jfc.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(evt.getPropertyName())) {
System.out.println(String.format("Value changed: %s -> %s", evt.getOldValue(), evt.getNewValue()));
}
}
});
frame.add(jfc);
frame.pack();
EventQueue.invokeLater(() -> frame.setVisible(true));
}
}
---------- END SOURCE ----------
- blocks
-
JDK-8316025 Use testUI() method of PassFailJFrame.Builder in FileChooserSymLinkTest.java
-
- Resolved
-
- causes
-
JDK-8307105 JFileChooser InvalidPathException when selecting some system folders on Windows
-
- Resolved
-
- duplicates
-
JDK-8015695 The selected shortcut file doesn't show the correct file path
-
- Closed
-
- relates to
-
JDK-8316029 Cover directory junctions in FileChooserSymLinkTest.java
-
- Open
-
(1 links to)