I have looked at this page on how to use the JavaFX FileChooser with Swing, and it works well: JavaFX FileChooser in swing
I have also looked at this page on how to make a stage now show in the taskbar with StageStyle.UTILITY: JavaFX: can you create a stage that doesn't show on the task bar and is undecorated?
However, when I combine the two, the file dialog that I use in the swing application opens a separate window in the taskbar, that does not appear with JFileChooser. I was wondering how to make the JavaFX FileChooser not show in the taskbar when using it in a swing application.
Here is a snippet of code that demonstrates the issue:
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javax.swing.JButton;
import javax.swing.JFrame;
import javafx.application.Platform;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
public class Test extends JFrame implements ActionListener {
private JButton button;
private FileChooser chooser;
public Test(){
super();
setDefaultCloseOperation(EXIT_ON_CLOSE);
button = new JButton("Test");
button.addActionListener(this);
add(button);
new javafx.embed.swing.JFXPanel();
Platform.setImplicitExit(false);
chooser = new FileChooser();
pack();
setLocationRelativeTo(null);
setVisible(true);
}
public void actionPerformed(ActionEvent e){
Platform.runLater(new Runnable(){
public void run(){
Stage stage = new Stage();
stage.initStyle(StageStyle.UTILITY);
File testfile = chooser.showOpenDialog(stage);
}
});
}
public static void main(String[] args){
new Test();
}
}