14
Ví dụ, tôi muốn mở một DirectoryChooser khi nhấp vào nút:Làm cách nào để có cửa sổ chính trong Bộ điều khiển FXML?
<VBox fx:controller="com.foo.MyController"
xmlns:fx="http://javafx.com/fxml">
<children>
<Button text="Click Me!" onAction="#handleButtonAction"/>
</children>
</VBox>
Và lớp điều khiển:
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.
}
}
Tôi muốn đặt Window chính đến ShowDialog để nó sẽ bị chặn nhưng làm cách nào tôi có thể truy cập?