當前位置: 首頁>>代碼示例>>Java>>正文


Java Button.setOnMousePressed方法代碼示例

本文整理匯總了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;
}
 
開發者ID:LtubSalad,項目名稱:voogasalad-ltub,代碼行數:19,代碼來源:GameManager.java

示例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);
	}
}
 
開發者ID:LtubSalad,項目名稱:voogasalad-ltub,代碼行數:18,代碼來源:GameManager.java

示例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);
}
 
開發者ID:LtubSalad,項目名稱:voogasalad-ltub,代碼行數:9,代碼來源:GameManager.java


注:本文中的javafx.scene.control.Button.setOnMousePressed方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。