Is there a way to expand the JFileChooser directory without a mouse

Using JFileChooser, I can select a directory by double-clicking on the directory (down the level). Is there a way to select a directory without a mouse? For example, is there a key binding to go to the directory level, or do I need to somehow add a key listener to JFileChooser?

+5
source share
3 answers

You can use the tab to move between the different parts of the selection, and then use the arrow keys to change the highlighted directory, and then press "Enter" to change the directory to the highlighted one.

(Vista/JDK 1.6), , :

import javax.swing.*;
public class test {
  public static void main(String[] args) {
      (new JFileChooser("")).showOpenDialog(new JFrame());
      System.out.println("OK!");
   }
}

JFileChooser, :

  • test.java , .
  • , - , , , UI, .. , , , , .
  • , , - , , ​​ JDK, .. .
+2

?

+1

ctrl + enter . , JFileChooser " ":

JFileChooser fileBrowser = new JFileChooser();
fileBrowser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
0
source

All Articles