本文整理汇总了Java中javafx.scene.control.Button.setOnMouseClicked方法的典型用法代码示例。如果您正苦于以下问题:Java Button.setOnMouseClicked方法的具体用法?Java Button.setOnMouseClicked怎么用?Java Button.setOnMouseClicked使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.Button
的用法示例。
在下文中一共展示了Button.setOnMouseClicked方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createGameFileChooserButton
import javafx.scene.control.Button; //导入方法依赖的package包/类
private Button createGameFileChooserButton() {
Button button = new Button();
Image image = new Image(NEW_GAME);
ImageView imageView = new ImageView(image);
imageView.setFitWidth(App.WIDTH / 3);
imageView.setPreserveRatio(true);
button.setGraphic(imageView);
//button.setWrapText(true);
button.setOnMouseClicked((e) -> {
FileLoader fileLoader = new FileLoader(primaryStage);
File fileChosen = fileLoader.chooseFile();
if (fileChosen != null) {
startGame(fileChosen);
}
});
// getRotation(button);
return button;
}
示例2: PasswordPane
import javafx.scene.control.Button; //导入方法依赖的package包/类
public PasswordPane()
{
super();
super.setPrefHeight(AppTabPane.CONTENT_HEIGHT);
super.setPrefWidth(AppTabPane.CONTENT_WIDTH);
super.getStyleClass().add("pane");
super.setPadding(new Insets(15,15,15,15));
super.setVgap(10);
buttons = new HBox();
buttons.setSpacing(10);
Label promptText = new Label("Sudo required.");
okButton = new Button("OK");
cancelButton = new Button("Cancel");
buttons.getChildren().addAll(okButton, cancelButton);
password = new PasswordField();
okButton.setPrefWidth(60);
okButton.setOnMouseClicked(new OkButtonHandler());
cancelButton.setOnMouseClicked(new CancelButtonHandler());
password.setPromptText("Password");
super.add(promptText, 0, 0);
super.add(password, 0, 1);
super.add(buttons, 0, 2);
}
示例3: NotifyTab
import javafx.scene.control.Button; //导入方法依赖的package包/类
public NotifyTab()
{
super();
super.setText("Notification");
super.setClosable(false);
pane = new Pane();
box = new VBox();
header = new Label();
desc = new Label();
okButton = new Button("Ok");
okButton.setPrefWidth(50);
okButton.setOnMouseClicked(new OkButtonHandler());
box.getChildren().addAll(header, desc, okButton);
box.setPadding(new Insets(15, 15, 15, 15));
box.setSpacing(15);
pane.setPrefHeight(AppTabPane.CONTENT_HEIGHT);
pane.setPrefWidth(AppTabPane.CONTENT_WIDTH);
pane.getChildren().add(box);
super.setContent(pane);
}
示例4: ImageVariableSetter
import javafx.scene.control.Button; //导入方法依赖的package包/类
public ImageVariableSetter(String variableName) {
super(variableName);
myImagePath=new SimpleStringProperty();
myContents=new VBox();
getChildren().add(myContents);
Button button= new Button("Choose Image File");
button.setOnMouseClicked((event)->{
FileChooser chooser=new FileChooser();
chooser.setInitialDirectory(base);
File imageFile=chooser.showOpenDialog(new Stage());
if(imageFile!=null){
File relativePath=new File(base.toURI().relativize(imageFile.toURI()).getPath());
myImagePath.set(relativePath.toString());
System.out.println(relativePath);
}
});
myContents.getChildren().addAll(new ImageDisplay(),button);
myContents.setSpacing(20);
System.out.println(base);
}
示例5: saveToFileButton
import javafx.scene.control.Button; //导入方法依赖的package包/类
/**
* Displays a save dialogue when pressed, to make sure the user wishes to save.
* @return
*/
private Button saveToFileButton(){
AlertHandler alertHandler = new AlertHandler();
Button saveButton = new Button("Save Sprite to File");
saveButton.setOnMouseClicked((click) -> {
Alert alert = alertHandler.confirmationPopUp("Are you sure you wish to save?");
Optional<ButtonType> result = alert.showAndWait();
if (result.isPresent() && result.get() == ButtonType.CANCEL) {
return;
}
SpriteMakerModel modelToSave = screen.produceNewModel();
if(modelToSave!=null){
XStreamHandler handler=new XStreamHandler();
if(handler.saveToFile(modelToSave)){
AlertHandler.showMessage("Saved successfully");
}
}
});
return saveButton;
}
示例6: makePostHighScoreBoard
import javafx.scene.control.Button; //导入方法依赖的package包/类
private Node makePostHighScoreBoard () {
HBox box = new HBox(5);
TextField field = new TextField("Game name");
ComboBox<ScoreOrder> combo = new ComboBox<>();
for (ScoreOrder s : ScoreOrder.values()) {
combo.getItems().add(s);
}
box.getChildren().addAll(field, combo);
Button button = new Button("Post global score board");
button.setOnMouseClicked(e -> {
myUser = mySocial.getActiveUser();
myUser.getProfiles().getActiveProfile().highScoreBoardPost(mySocial.getHighScoreBoard(),
field.getText(),
combo.getValue());
});
box.getChildren().add(button);
return box;
}
示例7: makeMyHighScorePost
import javafx.scene.control.Button; //导入方法依赖的package包/类
private Node makeMyHighScorePost () {
HBox box = new HBox(5);
TextField field = new TextField("Game name");
ComboBox<ScoreOrder> combo = new ComboBox<>();
for (ScoreOrder s : ScoreOrder.values()) {
combo.getItems().add(s);
}
box.getChildren().addAll(field, combo);
Button button = new Button("Post about my scores");
button.setOnMouseClicked(e -> {
myUser = mySocial.getActiveUser();
myUser.getProfiles().getActiveProfile().highScorePost(mySocial.getHighScoreBoard(),
field.getText(),
myUser,
combo.getValue());
});
box.getChildren().add(button);
return box;
}
示例8: FileVariableSetter
import javafx.scene.control.Button; //导入方法依赖的package包/类
public FileVariableSetter(String variableName) {
super(variableName);
Button fileChooser= new Button("Choose file");
fileLabel=new Label("No file chosen");
FileChooser chooser=new FileChooser();
chooser.setInitialDirectory(baseDirectory);
fileChooser.setOnMouseClicked((event)->{
File file=chooser.showOpenDialog(new Stage());
if(file!=null){
File relativePath=new File(baseDirectory.toURI().relativize(file.toURI()).getPath());
setField(relativePath);
}
});
this.getChildren().addAll(fileChooser,fileLabel);
;
}
示例9: PerformancePane
import javafx.scene.control.Button; //导入方法依赖的package包/类
public PerformancePane()
{
super();
super.setPrefHeight(AppTabPane.CONTENT_HEIGHT);
super.setPrefWidth(AppTabPane.CONTENT_WIDTH);
super.getStyleClass().add("vbox");
overclockingTabPane = new OverclockingTabPane();
apply = new Button("Apply All");
apply.setPrefWidth(100);
apply.setPrefHeight(54);
cancel = new Button("Reset All");
cancel.setPrefWidth(100);
cancel.setPrefHeight(54);
buttonPane = new VBox();
buttonPane.getChildren().addAll(apply, cancel);
overclockingPane = new HBox();
overclockingPane.getChildren().addAll(overclockingTabPane, buttonPane);
apply.setOnMouseClicked(new ApplyButtonHandler());
cancel.setOnMouseClicked(new cancelButtonHandler());
super.getChildren().addAll(new PowerMizerPane(), overclockingPane);
}
示例10: FanProfilePane
import javafx.scene.control.Button; //导入方法依赖的package包/类
public FanProfilePane()
{
super();
super.setPrefHeight(AppTabPane.CONTENT_HEIGHT);
super.setPrefWidth(AppTabPane.CONTENT_WIDTH);
editPane = new FanProfileEditPane(InstanceProvider.getFanProfiles().get(0));
leftPane = new VBox();
profileList = new ListView<>();
profileList.setEditable(false);
profileList.setPrefWidth(125);
profileList.setItems(FXCollections.observableArrayList(InstanceProvider.getFanProfiles()));
profileList.getSelectionModel().selectFirst();
profileList.setOnMouseClicked(new ListHandler());
profileList.setContextMenu(new ProfileContextMenu(profileList));
profileList.setPlaceholder(new Label("No Profiles"));
applyButton = new Button("Apply");
applyButton.setPrefWidth(125);
applyButton.setMinHeight(47);
applyButton.setOnMouseClicked(new ApplyButtonHandler());
leftPane.getChildren().addAll(profileList, applyButton);
infoPane = new FanOptionPane();
super.setTop(infoPane);
super.setLeft(leftPane);
super.setCenter(editPane);
}
示例11: createContent
import javafx.scene.control.Button; //导入方法依赖的package包/类
public void createContent() {
content = new VBox();
spawnTime = new DoubleParameterInput("Time between spawn (sec)", 0, 10);
spawnTime.getDoubleProperty().addListener(e -> getData().setSpawnTime(spawnTime.getValue()));
Button addSpawner = new Button("Add this Spawner to this Level");
addSpawner.setOnMouseClicked(e -> {
System.out.println("spawn " + spawnerCreation.getSpawner(spawnTime.getValue()) == null);
getData().addSpawner(spawnerCreation.getSpawner(spawnTime.getValue()));
});
content.getChildren().addAll(spawnTime, addSpawner);
this.setContent(content);
}
示例12: makeChallenge
import javafx.scene.control.Button; //导入方法依赖的package包/类
private Node makeChallenge () {
HBox box = new HBox(5);
TextField field = new TextField("Challenge text");
box.getChildren().add(field);
Button button = new Button("Challenge");
button.setOnMouseClicked(e -> {
myUser = mySocial.getActiveUser();
// myUser.getProfiles().getActiveProfile().challenge(myUser, myUser, field.getText());
});
box.getChildren().add(button);
return box;
}
示例13: makePost
import javafx.scene.control.Button; //导入方法依赖的package包/类
private Node makePost () {
HBox box = new HBox(5);
TextField field = new TextField();
box.getChildren().add(field);
Button button = new Button("Custom Post");
button.setOnMouseClicked(e -> post(field));
box.getChildren().add(button);
return box;
}
示例14: makeNotify
import javafx.scene.control.Button; //导入方法依赖的package包/类
private Node makeNotify () {
HBox box = new HBox(5);
TextField field = new TextField();
box.getChildren().add(field);
Button button = new Button("Notify all users");
button.setOnMouseClicked(e -> notify(field));
box.getChildren().add(button);
return box;
}
示例15: showSvgs
import javafx.scene.control.Button; //导入方法依赖的package包/类
private void showSvgs(int index) {
int x = 0, y = 0;
for (String j :
svgData.get(index).getValue().getData().values()) {
SVGPath path = new SVGPath();
path.setContent(j);
Bounds bounds = path.boundsInLocalProperty().getValue();
double scale = Math.max(bounds.getHeight(),bounds.getWidth());
path.setScaleX(30 / scale);
path.setScaleY(30 / scale);
Button button = new Button();
button.setGraphic(path);
button.getStylesheets().add("css/svgbutton_style.css");
button.setOnMouseClicked(event -> {
SVGPath svgPath = (SVGPath) button.getGraphic();
controller.drawSvg(svgPath.getContent());
(button.getScene().getWindow()).hide();
});
button.setManaged(false);
button.resizeRelocate(x , y, 50, 50);
x+=55;
if (x > 399) {
x = 0;
y += 55;
}
iconsPane.getChildren().add(button);
}
}