本文整理汇总了Java中javafx.scene.control.Button.setOnMousePressed方法的典型用法代码示例。如果您正苦于以下问题:Java Button.setOnMousePressed方法的具体用法?Java Button.setOnMousePressed怎么用?Java Button.setOnMousePressed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.Button
的用法示例。
在下文中一共展示了Button.setOnMousePressed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initSystemSettings
import javafx.scene.control.Button; //导入方法依赖的package包/类
private HBox initSystemSettings() {
HBox settingBox = new HBox();
settingBox.setAlignment(Pos.TOP_RIGHT);
settingBox.setSpacing(15);
Button musicButton = new Button();
ImageView musicImageView = new ImageView(
new Image(getClass().getClassLoader().getResourceAsStream(myResources.getString("music"))));
musicImageView.setFitWidth(20);
musicImageView.setPreserveRatio(true);
musicButton.setGraphic(musicImageView);
musicButton.setOnMousePressed(e -> {
// TODO show a menu of several choices of background music
System.out.println("Here should be a menu of background music choices.");
});
settingBox.getChildren().add(musicButton);
return settingBox;
}
示例2: addDefaultChoices
import javafx.scene.control.Button; //导入方法依赖的package包/类
private void addDefaultChoices(VBox gameButtonBox) {
for (int i = 0; i < numberOfDefaultGames; i++) {
String fileName = myResources.getString("defaultGamePath" + (i + 1));
Image gameImage = new Image(getClass().getClassLoader().getResourceAsStream(fileName));
ImageView gameImageView = new ImageView(gameImage);
gameImageView.setFitWidth(App.WIDTH / 3);
gameImageView.setPreserveRatio(true);
Button gameButton = new Button();
// TODO
gameButton.setTooltip(new Tooltip(myResources.getString("defaultGameName" + (i + 1))));
gameButton.setOnMousePressed(e -> {
loadGameFile(false, gameButton);
});
gameButton.setGraphic(gameImageView);
gameButtonBox.getChildren().add(gameButton);
}
}
示例3: addCustomChoice
import javafx.scene.control.Button; //导入方法依赖的package包/类
private void addCustomChoice(VBox gameButtonBox) {
Button customGameButton = new Button("Load another Game");
customGameButton.setOnMousePressed(e -> {
loadGameFile(true, customGameButton);
});
customGameButton.setWrapText(true);
gameButtonBox.getChildren().add(customGameButton);
}