I'm learning java swing recently. Please don't tell me it's out of date. I know. I want to create a folder selector like this, there is nothing extra.
Instead of the following, there are many other elements on it
I'm learning java swing recently. Please don't tell me it's out of date. I know. I want to create a folder selector like this, there is nothing extra.
Instead of the following, there are many other elements on it
java swing has a jfilechooser
which you can use. refer Java Swing Here
https://docs.oracle.com/javase/7/docs/api/javax/swing/JFileChooser.html
You can use JavaFX:
DirectoryChooser directoryChooser = new DirectoryChooser();
directoryChooser.setInitialDirectory(new File("src"));
Button button = new Button("Select Directory");
button.setOnAction(e -> {
File selectedDirectory = directoryChooser.showDialog(primaryStage);
System.out.println(selectedDirectory.getAbsolutePath());
});
Javadoc: https://docs.oracle.com/javase/10/docs/api/javafx/stage/DirectoryChooser.html
It does indeed call the Windows browse for folder dialog:
Win32 docs: https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shbrowseforfolderw