Java 如何将JFileChooser放在舞台顶部

Java 如何将JFileChooser放在舞台顶部,java,javafx,jfilechooser,Java,Javafx,Jfilechooser,我有一个JFileChooser,我想显示在一个阶段的顶部(parentStage下面)。我该怎么做呢 我希望JFileChooser具有与Stage在Stage.initOwner(initOwner)时相同的行为已设置 @Autowired MyStagesClass myStagesClass; public JFileChooser jFileChooser() throws Exception { UIManager.setLookAndFeel(UIManager.getS

我有一个JFileChooser,我想显示在一个阶段的顶部(
parentStage
下面)。我该怎么做呢

我希望JFileChooser具有与
Stage
Stage.initOwner(initOwner)时相同的行为已设置

@Autowired
MyStagesClass myStagesClass;

public JFileChooser jFileChooser() throws Exception {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

    chooser.setMultiSelectionEnabled(true);
    chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);

    chooser.updateUI(); // Create UI objects
    UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    refreshUI(chooser, false);

    Stage parentStage = myStagesClass.getStage();

    chooser.showOpenDialog(null);

    return chooser;
}

您不必使用JFileChooser的showOpenDialog方法。JFileChooser实际上是一个JComponent,所以请将它放在中,然后将SwingNode放在DialogPane中(或者如果使用旧版本的JavaFX,则放在场景中的Group或BorderPane中)。我强烈建议不要在同一应用程序中混合Swing窗口和FX窗口。要么按照@VGR的建议,将
JFileChooser
包装在
SwingNode
Stage
中,要么只使用
javafx.Stage.FileChooser
@James\u D。我认为使用JFileChooser可能是因为JavaFX的选择器没有与
setFileSelectionMode(JFileChooser.FILES\u和\u目录)
等价的选项。。。你确定要这样做吗
JFileChooser
在功能和外观上都是垃圾。
javafx.stage.FileChooser
要好得多。您应该使用它,而不必使用JFileChooser的showOpenDialog方法。JFileChooser实际上是一个JComponent,所以请将它放在中,然后将SwingNode放在DialogPane中(或者如果使用旧版本的JavaFX,则放在场景中的Group或BorderPane中)。我强烈建议不要在同一应用程序中混合Swing窗口和FX窗口。要么按照@VGR的建议,将
JFileChooser
包装在
SwingNode
Stage
中,要么只使用
javafx.Stage.FileChooser
@James\u D。我认为使用JFileChooser可能是因为JavaFX的选择器没有与
setFileSelectionMode(JFileChooser.FILES\u和\u目录)
等价的选项。。。你确定要这样做吗
JFileChooser
在功能和外观上都是垃圾。
javafx.stage.FileChooser
要好得多。你应该用它来代替。