JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogType(JFileChooser.DIRECTORIES_ONLY);By setting the dialog type to DIRECTORIES_ONLY, the file chooser will allow the user to select only directories, not individual files. All of these examples use the javax.swing package library in Java, specifically the JFileChooser class. They demonstrate how the setDialogType() method can be used to customize the behavior of the file chooser dialog window to suit different needs.