Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

steffen678/NativeJFileChooser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

4 Commits

Repository files navigation

NativeJFileChooser

This is a drop-in replacement for Swing's file chooser. Instead of displaying the Swing file chooser, it makes use of the JavaFX file chooser if available. It still uses Swing's file chooser as a fallback.

Usage

NativeJFileChooser is available via Maven:

<dependency>
 <groupId>li.flor</groupId>
 <artifactId>native-j-file-chooser</artifactId>
 <version>1.6.4</version>
</dependency>

Simply replace

JFileChooser fileChooser = new JFileChooser();

with

JFileChooser fileChooser = new NativeJFileChooser();

Example

EventQueue.invokeLater(() -> {
 JFrame frame = new JFrame("Test");
 JButton button = new JButton("Click me!");
 JFileChooser fileChooser = new NativeJFileChooser();
 fileChooser.setFileFilter(new FileNameExtensionFilter("JPG", "*.jpg"));
 button.addActionListener((ActionEvent e) -> {
 fileChooser.showDialog(frame, "Open");
 });
 frame.add(button);
 frame.setLocationRelativeTo(null);
 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 frame.pack();
 frame.setVisible(true);
});

About

Native file chooser for Swing using JavaFX if available

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

AltStyle によって変換されたページ (->オリジナル) /