如何将处理程序分配给最小化(iconify)应用程序到 Controller 的public void初始化(URL,ResourceBundle)中的
方法? @FXML private HBox minBtn;
(使用Shape制作的自定义按钮)按钮)setIconified(boolean)
方法位于 Stage 类中,但我无法在我的 Controller 类中获取他。
最佳答案
您可以通过以下方式访问舞台
minBtn.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent arg0) {
((Stage) ((Node) arg0.getSource()).getScene().getWindow()).setIconified(true);
// OR
((Stage) minBtn.getScene().getWindow()).setIconified(true);
}
});
关于java - 如何最小化(图标化)FXML应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11526107/