我有一个javaFx项目,我想在Controller内部实现一个方法,每次阶段(窗口)关闭时调用它,以便能够在关闭它之前执行某些操作.将方法放置在控制器内的愿望是因为要采取的动作取决于用户在使用场景时做出的选择.
我的目标是每次用户关闭舞台,进行打印,然后进行与用户相关的操作.
我在控制器类中尝试:
@FXML
public void exitApplication(ActionEvent event) {
System.out.println("stop");
action();
Platform.exit();
}
Run Code Online (Sandbox Code Playgroud)
但它没有效果.
我有这个:
一个带左节点的边框窗格(绿色箭头),里面有按钮(橙色箭头)。
我不能做的是找到一种方法来根据窗口的大小更改 Vbox(绿色段)的尺寸,然后更改按钮(橙色段)的尺寸。(当用户播放窗口大小时)
我更喜欢找到一种方法将参数设置到我的 css 文件中,或者作为最后的手段在我的 fxml 中。
.css 文件:
.left-borderPane{ /*this is style class for Vbox */
/*something so similar: */
-fx-min-width:30% ;
-fx-max-width:30% ;
}
.icon-settings{/*this is style class for buttons*/
-fx-shape:"M72.5,65.9 M90,50c0,8.6-2.5,16.9-7.3,24.1c-0.4,0.6-1,0.9-1.7,0.9c-0.4,0-0.8-0.1-1.1-0.3c-0.9-0.6-1.2-1.8-0.6-2.50zM69.6,50c0,3.2-0.6,6.2-1.8,9.1c-0.3,0.8-1.1,1.2-1.8,1.2c-0.2,0-0.5,0-0.8-0.1c-1-0.4c0.6-0.6,1.4-0.7,2.2-0.4C57.5,14.5,58,15.2,58,16z M35,37H14v26h21V37z M54,20.8l-15,15v28.3l15,15V20.8z";
/*something so similar: */
-fx-min-width:80% ;
-fx-max-width:80% ;
}
Run Code Online (Sandbox Code Playgroud)