例如,我想在单击按钮时打开一个 DirectoryChooser:
<VBox fx:controller="com.foo.MyController"
xmlns:fx="http://javafx.com/fxml">
<children>
<Button text="Click Me!" onAction="#handleButtonAction"/>
</children>
</VBox>
和控制器类:
package com.foo;
public class MyController {
public void handleButtonAction(ActionEvent event) {
DirectoryChooser dc = new DirectoryChooser();
File folder = dc.showDialog(null);//I want to put the WIndows here.
}
}
我想把主窗口放到ShowDialog中,这样它就会被阻止,但我怎样才能访问它呢?