本文整理匯總了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);
}