当前位置: 首页>>代码示例>>Java>>正文


Java Button.setOnAction方法代码示例

本文整理汇总了Java中javafx.scene.control.Button.setOnAction方法的典型用法代码示例。如果您正苦于以下问题:Java Button.setOnAction方法的具体用法?Java Button.setOnAction怎么用?Java Button.setOnAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.control.Button的用法示例。


在下文中一共展示了Button.setOnAction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import javafx.scene.control.Button; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {

    Label welMessage = new Label("Welcome to Collin Tod's Pitman Shorthand Translator!");
    Button enter = new Button("Enter");
    VBox pane = new VBox(5);
    pane.setAlignment(Pos.CENTER);
    pane.getChildren().addAll(welMessage, enter);
    Scene welcome = new Scene(pane);

    enter.setOnAction(event -> {
        try {
            Platform.exit();
        } catch (Exception e) {
            e.printStackTrace();
        }
    });

    primaryStage.setScene(welcome);
    primaryStage.setTitle("Welcome to the Pitman Translator!");
    primaryStage.show();
}
 
开发者ID:squablyScientist,项目名称:Pitman-Translator,代码行数:23,代码来源:Landing.java

示例2: MonsterAdder

import javafx.scene.control.Button; //导入方法依赖的package包/类
public MonsterAdder(AllPossibleMonsters possibleMonsters) {
	myPossibleMonsters = possibleMonsters;
	loadMonster = new Button(LOAD_A_MONSTER_FROM_FILE);
	loadMonster.setOnAction(click -> {
		XStreamHandler xstream = new XStreamHandler();
		SpriteMakerModel monster = (SpriteMakerModel) xstream.getAttributeFromFile();
		myPossibleMonsters.loadFromFile(monster);
	});
	
	refresh = new Button("Refresh");
	refresh.setOnAction(click -> {
		myPossibleMonsters.getMonstersOnScreen();
	});
	
	this.getChildren().addAll(new Text(CREATE_A_SPAWNER), loadMonster, //refresh, 
			numberOfMonsters);		
}
 
开发者ID:LtubSalad,项目名称:voogasalad-ltub,代码行数:18,代码来源:MonsterAdder.java

示例3: createSaveAction

import javafx.scene.control.Button; //导入方法依赖的package包/类
/**
 * Create the save action.
 *
 * @return the button
 */
protected @NotNull Button createSaveAction() {

    final Button action = new Button();
    action.setTooltip(new Tooltip(Messages.FILE_EDITOR_ACTION_SAVE + " (Ctrl + S)"));
    action.setOnAction(event -> save());
    action.setGraphic(new ImageView(Icons.SAVE_16));
    action.disableProperty().bind(dirtyProperty().not());

    FXUtils.addClassesTo(action, CSSClasses.FLAT_BUTTON,
            CSSClasses.FILE_EDITOR_TOOLBAR_BUTTON);

    DynamicIconSupport.addSupport(action);

    return action;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:21,代码来源:AbstractFileEditor.java

示例4: start

import javafx.scene.control.Button; //导入方法依赖的package包/类
@Override public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle("Simple Web Server");
    BorderPane root = new BorderPane();
    TextArea area = new TextArea();
    root.setCenter(area);
    ToolBar bar = new ToolBar();
    Button openInBrowser = FXUIUtils.createButton("open-in-browser", "Open in External Browser", true);
    openInBrowser.setOnAction((event) -> {
        try {
            Desktop.getDesktop().browse(URI.create(webRoot));
        } catch (IOException e) {
            e.printStackTrace();
        }
    });
    Button changeRoot = FXUIUtils.createButton("fldr_closed", "Change Web Root", true);
    changeRoot.setOnAction((event) -> {
        DirectoryChooser chooser = new DirectoryChooser();
        File showDialog = chooser.showDialog(primaryStage);
        if (showDialog != null)
            server.setRoot(showDialog);
    });
    bar.getItems().add(openInBrowser);
    bar.getItems().add(changeRoot);
    root.setTop(bar);
    System.setOut(new PrintStream(new Console(area)));
    System.setErr(new PrintStream(new Console(area)));
    area.setEditable(false);
    primaryStage.setScene(new Scene(root));
    primaryStage.setOnShown((e) -> startServer(getParameters().getRaw()));
    primaryStage.show();
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:32,代码来源:SimpleWebServer.java

示例5: seiInitState

import javafx.scene.control.Button; //导入方法依赖的package包/类
public void seiInitState(final Pane pane, final Button buttonToOpen, final Button btn_play_video,
                         final Button btn_stop_video, final Button btn_pause_video, final Slider time_slider,
                         final Slider volume_audio_slider, final Label time_lbl) {
    buttonToOpen.setOnAction(action -> {
        final File singleFileFromOpenedDialog = getFileChooserForVideo(primaryStage);
        if (singleFileFromOpenedDialog != null) {
            try {
                readFileAndSetInitialStateForVideoItem(singleFileFromOpenedDialog, pane);
                setupControlButtons(btn_play_video, btn_stop_video, btn_pause_video);
                setupTimeSliderDependsOnMediaPlayer(time_slider, time_lbl);
                setupVolumeSliderDependsOnMediaPlayer(volume_audio_slider);
            } catch (IOException e1) {
                LOGGER.error("An error: \n" + e1.getCause());
            }
        }
    });

}
 
开发者ID:Evegen55,项目名称:main_carauto_board,代码行数:19,代码来源:VideoController.java

示例6: display

import javafx.scene.control.Button; //导入方法依赖的package包/类
public static void display(String title, String message)
{
	Stage window= new Stage();
	window.initModality(Modality.APPLICATION_MODAL);
	//window.setAlwaysOnTop(true);
	window.getIcons().add(new Image("/pic/slogo.png"));
	window.setTitle(title);
	Label label= new Label();
	label.setText(message);
	label.setStyle("-fx-font-size:14px;");
	
	ImageView imageView = new ImageView(ICON);
	imageView.setFitWidth(40);
	imageView.setFitHeight(40);
       Label labelimage = new Label("",imageView);
	
	// two buttons
	Button okbtn= new Button("Ok");
	okbtn.setOnAction(e -> {
		answer= false;
		window.close();
	});
	okbtn.setId("red");
	HBox hbox= new HBox(10);
	hbox.setAlignment(Pos.CENTER_LEFT);
	hbox.setPadding(new Insets(10,5,10,5));
	hbox.getChildren().addAll(labelimage,label);
	VBox layout= new VBox(15);
	layout.setAlignment(Pos.CENTER_RIGHT);
	layout.setPadding(new Insets(10,5,10,5));
	layout.getChildren().addAll(hbox,okbtn);
	layout.setStyle("-fx-background-color: linear-gradient(#E4EAA2, #9CD672);");
	Scene scene= new Scene(layout);
	scene.getStylesheets().add(ErrorMessage.class.getResource("confirm.css").toExternalForm());
	window.setScene(scene);
	window.setResizable(false);
	window.showAndWait();
}
 
开发者ID:mikemacharia39,项目名称:gatepass,代码行数:39,代码来源:ErrorMessage.java

示例7: createHeaderPane

import javafx.scene.control.Button; //导入方法依赖的package包/类
public Node createHeaderPane(WeekView calView) {
    final GridPane container = new GridPane();
    container.setAlignment(Pos.BOTTOM_LEFT);
    container.getStyleClass().add("headerpane");

    final Label lblWeekday = new Label(calView.getDate().get().format(DateTimeFormatter.ofPattern("EEE")));
    lblWeekday.getStyleClass().add("label-weekday");

    final Label lblDate = new Label(calView.getDate().get().toString());
    lblDate.getStyleClass().add("label-date");
    final ContextMenu dayChooserMenu = new ContextMenu();
    final CustomMenuItem item = new CustomMenuItem(new DayChooser(calView.getDate()));
    dayChooserMenu.getStyleClass().add("day-chooser");
    item.setHideOnClick(false);
    dayChooserMenu.getItems().add(item);
    lblDate.setOnMouseClicked(event ->
            dayChooserMenu.show(lblDate,
                    lblDate.localToScreen(0, 0).getX(),
                    lblDate.localToScreen(0, 0).getY())
    );

    final Button left = new Button("<");
    left.getStyleClass().add("header-button");
    left.setOnAction(event -> calView.getDate().set(calView.getDate().get().minusDays(1)));
    final Button right = new Button(">");
    right.getStyleClass().add("header-button");
    right.setOnAction(event -> calView.getDate().set(calView.getDate().get().plusDays(1)));

    final ColumnConstraints columnWeekday = new ColumnConstraints(70);
    final ColumnConstraints columnCenter = new ColumnConstraints(20,50,Double.POSITIVE_INFINITY, Priority.ALWAYS, HPos.LEFT,true);
    final ColumnConstraints columnSwitcher = new ColumnConstraints(60);
    container.getColumnConstraints().addAll(columnWeekday, columnCenter, columnSwitcher);
    container.add(lblWeekday,0,0);
    container.add(lblDate, 1,0);
    container.add(new HBox(left, right), 2,0);
    return container;
}
 
开发者ID:Jibbow,项目名称:FastisFX,代码行数:38,代码来源:WeekViewRenderer.java

示例8: createBox

import javafx.scene.control.Button; //导入方法依赖的package包/类
private void createBox(){
	//TODO resource file
	fileChoose = new Button(myResources.getString("IMAGE_CHOOSE"));
	//TODO check for image path
	fileChoose.setOnAction(e -> imagePath.setText(new FileChooser().showOpenDialog(new Stage()).toString()));
	this.getChildren().addAll(new Text(varName), fileChoose);
}
 
开发者ID:LtubSalad,项目名称:voogasalad-ltub,代码行数:8,代码来源:ImageParameterInput.java

示例9: setInfo

import javafx.scene.control.Button; //导入方法依赖的package包/类
public void setInfo(){
    List<File> previouslyAddedAttachments = null;
    if(formattedMessage != null && message != null){
        toTextField.setText(formattedMessage.getToEmailId());
        fromTextField.setText(formattedMessage.getFromEmailId());
        subTextField.setText(formattedMessage.getSubject());
        composeTextArea.setText(formattedMessage.getBodyText());
        try {
            previouslyAddedAttachments = GmailOperations.downloadAttachments(message,System.getProperty("user.home")+"/temp");
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (previouslyAddedAttachments != null) {
            for(File f: previouslyAddedAttachments){
                Button b = new Button(f.getName());
                attachedFilesButtonParent.getButtons().add(b);
                b.setOnAction(new EventHandler<ActionEvent>() {
                    @Override
                    public void handle(ActionEvent event) {
                        attachments.remove(attachedFilesButtonParent.getButtons().indexOf(b));
                        attachedFilesButtonParent.getButtons().remove(b);
                    }
                });
                attachments.add(f);
            }
        }
        /*try {
            previouslyAddedAttachments = GmailOperations.getAttachments(message);
        } catch (IOException e) {
            e.printStackTrace();
        }*/
    }

}
 
开发者ID:ashoknailwal,项目名称:desktop-gmail-client,代码行数:35,代码来源:ComposeActivity.java

示例10: createControls

import javafx.scene.control.Button; //导入方法依赖的package包/类
/**
 * Create controls.
 */
private void createControls() {

    final Label propertyNameLabel = new Label(getControlTitle() + ":");

    elementContainer = new VBox();

    final Button addButton = new Button();
    addButton.setGraphic(new ImageView(Icons.ADD_16));
    addButton.setOnAction(event -> processAdd());

    final Button removeButton = new Button();
    removeButton.setGraphic(new ImageView(Icons.REMOVE_12));
    removeButton.setOnAction(event -> processRemove());
    removeButton.setDisable(true);

    final HBox buttonContainer = new HBox(addButton, removeButton);

    final ObservableList<Node> children = elementContainer.getChildren();
    children.addListener((ListChangeListener<Node>) c -> removeButton.setDisable(children.size() < (getMinElements() + 1)));

    FXUtils.addToPane(propertyNameLabel, this);
    FXUtils.addToPane(elementContainer, this);
    FXUtils.addToPane(buttonContainer, this);

    FXUtils.addClassTo(propertyNameLabel, CSSClasses.ABSTRACT_PARAM_CONTROL_PARAM_NAME_SINGLE_ROW);
    FXUtils.addClassTo(addButton, CSSClasses.BUTTON_WITHOUT_RIGHT_BORDER);
    FXUtils.addClassTo(removeButton, CSSClasses.BUTTON_WITHOUT_LEFT_BORDER);
    FXUtils.addClassTo(buttonContainer, CSSClasses.DEF_HBOX);
    FXUtils.addClassTo(elementContainer, CSSClasses.DEF_VBOX);

    DynamicIconSupport.addSupport(addButton, removeButton);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:36,代码来源:PhysicsNodeListControl.java

示例11: createControls

import javafx.scene.control.Button; //导入方法依赖的package包/类
/**
 * Create controls.
 */
protected void createControls() {

    final Label propertyNameLabel = new Label(getControlTitle() + ":");

    elementContainer = new VBox();

    final Button addButton = new Button();
    addButton.setGraphic(new ImageView(Icons.ADD_16));
    addButton.setOnAction(event -> processAdd());

    final Button removeButton = new Button();
    removeButton.setGraphic(new ImageView(Icons.REMOVE_12));
    removeButton.setOnAction(event -> processRemove());

    final HBox buttonContainer = new HBox(addButton, removeButton);

    final ObservableList<Node> children = elementContainer.getChildren();
    children.addListener((ListChangeListener<Node>) c -> removeButton.setDisable(children.size() < (getMinElements() + 1)));

    FXUtils.addToPane(propertyNameLabel, this);
    FXUtils.addToPane(elementContainer, this);
    FXUtils.addToPane(buttonContainer, this);

    FXUtils.addClassTo(propertyNameLabel, CSSClasses.ABSTRACT_PARAM_CONTROL_PARAM_NAME_SINGLE_ROW);
    FXUtils.addClassTo(elementContainer, CSSClasses.DEF_VBOX);
    FXUtils.addClassTo(addButton, CSSClasses.BUTTON_WITHOUT_RIGHT_BORDER);
    FXUtils.addClassTo(removeButton, CSSClasses.BUTTON_WITHOUT_LEFT_BORDER);
    FXUtils.addClassTo(buttonContainer, CSSClasses.DEF_HBOX);

    DynamicIconSupport.addSupport(addButton, removeButton);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:35,代码来源:AbstractInterpolationInfluencerControl.java

示例12: buildDirectoryChooser

import javafx.scene.control.Button; //导入方法依赖的package包/类
private static Button buildDirectoryChooser(Configuration configuration,
        ConfigurationContext configurationContext) {

    final String filedir = configuration.getFiledir();

    Button buttonLoad = new Button(filedir);

    buttonLoad.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent arg0) {
            DirectoryChooser directoryChooser = new DirectoryChooser();
            File file = directoryChooser.showDialog(configurationContext.getScene().getWindow());
            if (file == null) {
                return;
            }
            buttonLoad.setText(file.toString() + Utils.FILESEPARATOR);

            String newPropertyValue = file.toString() + Utils.FILESEPARATOR;

            if (Utils.isWindows()) {
                newPropertyValue = Utils.convertWindowsPath(newPropertyValue);
            }

            ConfigurationBuilder.createFromPropertiesResource().withFileDir(newPropertyValue)
                    .saveConfigIgnoringExceptions();
        }
    });

    return buttonLoad;
}
 
开发者ID:schwabdidier,项目名称:GazePlay,代码行数:31,代码来源:ConfigurationContext.java

示例13: getActionPane

import javafx.scene.control.Button; //导入方法依赖的package包/类
private VBox getActionPane(){
progress= new Text("Office\nEntry Progress");
progress.setTextAlignment(TextAlignment.CENTER);
progress.setFont(Font.font("Times New Roman", 35));
lname= new Label("-Your Name here-");

Image iconf= new Image(Office_Entry.class.getResourceAsStream("/pic/finger.png"));
ImageView ivconf= new ImageView(iconf);
lpic= new Label();
lpic.setGraphic(ivconf);

Image img1= new Image(PersonalReports.class.getResourceAsStream("/pic/cross.png"));
ImageView imagvw= new ImageView(img1);
imagvw.setFitHeight(70);
imagvw.setFitWidth(70);
lnotexist= new Label("",imagvw);
lnotexist.setText("\n\n\n\n\nN/A");
lnotexist.setFont(Font.font("Cooper Black", 15));
lnotexist.setVisible(false);

txtfinger= new TextField();
txtfinger.setEditable(false);
txtfinger.setMaxWidth(160);		
txtfinger.setStyle("-fx-background-radius:10; -fx-background-color:#9CD777;");

txtsearch= new TextField();
initFilter();

Button btnView= new Button("View Records");
Button btnCloseView= new Button("Hide Records");

Button btnadd= new Button("save");
btnadd.setOnAction(e -> {
	setAddAttendance();
});

btnView.setOnAction(e -> {
	timelineDown.play();
});
btnCloseView.setOnAction(e -> {
	timelineUp.play();
});


VBox laywrong= new VBox();
laywrong.getChildren().addAll(lnotexist);
laywrong.setPadding(new Insets(0,0,0,0));
laywrong.setAlignment(Pos.CENTER);

HBox laytest= new HBox(5);
laytest.getChildren().addAll(txtfinger /* btnadd*/);
laytest.setAlignment(Pos.CENTER);

VBox laybtnsearch= new VBox();
laybtnsearch.getChildren().addAll(txtsearch);
laybtnsearch.setAlignment(Pos.CENTER);
laybtnsearch.setPadding(new Insets(20,0,0,0));

HBox laybtn= new HBox(5);
laybtn.getChildren().addAll(btnView, btnCloseView);
laybtn.setAlignment(Pos.CENTER);
VBox lay1= new VBox(10);
lay1.getChildren().addAll(progress, lpic, lname, laytest);
lay1.setAlignment(Pos.CENTER);
VBox layside= new VBox(25);
layside.getChildren().addAll(lay1, laybtn, laybtnsearch, laywrong);
layside.setAlignment(Pos.TOP_CENTER);
layside.setMinWidth(230);
layside.setPadding(new Insets(20,0,10,0));
return layside;
 }
 
开发者ID:mikemacharia39,项目名称:gatepass,代码行数:72,代码来源:Office_Entry.java

示例14: renderAccountCard

import javafx.scene.control.Button; //导入方法依赖的package包/类
private void renderAccountCard(Account account) {
	Pane pane = new AnchorPane();
	addCssClass(pane, "account-card");
	pane.setPrefHeight(70.0);
	pane.setMinHeight(70.0);
	pane.setMaxHeight(70.0);
	List<Node> children = pane.getChildren();

	Label domainLabel = new Label(account.getDomain());
	children.add(domainLabel);
	addCssClass(domainLabel, "domain-label");
	UiCommons.assignAnchors(domainLabel, 5.0, 100.0, null, 5.0);

	Label usernameLabel = new Label(account.getUsername());
	children.add(usernameLabel);
	addCssClass(usernameLabel, "username-label");
	UiCommons.assignAnchors(usernameLabel, 10.0, 100.0, 15.0, 10.0);

	Button showButton = new Button("Show");
	children.add(showButton);
	addCssClass(showButton, "control");
	showButton.setFocusTraversable(false);
	showButton.setOnAction(event -> showModal(new PasswordRevealModal(), account));
	UiCommons.assignAnchors(showButton, 5.0, 10.0, null, null);

	MenuButton accountMenu = new MenuButton("\u2699");
	children.add(accountMenu);
	addCssClass(accountMenu, "control");
	accountMenu.setFocusTraversable(false);
	UiCommons.assignAnchors(accountMenu, null, 10.0, 5.0, null);

	List<MenuItem> menuItems = accountMenu.getItems();
	MenuItem updateMenuItem = new MenuItem("Update");
	menuItems.add(updateMenuItem);
	updateMenuItem.setOnAction(event -> showModalWithReload(new SaveAccountModal(), Optional.of(account)));

	MenuItem deleteMenuItem = new MenuItem("Delete");
	menuItems.add(deleteMenuItem);
	deleteMenuItem.setOnAction(event -> showModalWithReload(new DeleteAccountModal(), account));

	viewPane.getChildren()
			.add(pane);
}
 
开发者ID:kana0011,项目名称:symmetrical-memory,代码行数:44,代码来源:MainFormController.java

示例15: Mesazhi

import javafx.scene.control.Button; //导入方法依赖的package包/类
public Mesazhi(String titulli, String titulli_msg, String mesazhi, ShikoPunetoret sp, DritarjaKryesore dk){
    stage.setTitle(titulli);
    stage.initModality(Modality.APPLICATION_MODAL);
    stage.setResizable(false);
    Button btnAnulo = new Button("Anulo");
    HBox root = new HBox(15);
    VBox sub_root = new VBox(10);
    HBox btn = new HBox(5);
    Text ttl = new Text(titulli_msg);
    ttl.setFont(Font.font(16));
    Button btnOk = new Button("Ne rregull");
    btn.getChildren().addAll(btnAnulo, btnOk);
    btn.setAlignment(Pos.CENTER_RIGHT);

    btnOk.setOnAction(e -> {
        sp.fshi(sp.strEmri.toLowerCase() + sp.strMbiemri.toLowerCase());
        stage.close();
    });
    btnOk.setOnKeyPressed(e -> {
        if (e.getCode().equals(KeyCode.ENTER)) stage.close();
        else if (e.getCode().equals(KeyCode.ESCAPE)) stage.close();
    });

    btnAnulo.setOnAction(e -> stage.close());

    root.setPadding(new Insets(20));
    sub_root.getChildren().addAll(ttl, new Label(mesazhi), btn);
    if (titulli == "Gabim")
        root.getChildren().add(new ImageView(new Image("/sample/foto/error.png")));
    else if (titulli == "Sukses")
        root.getChildren().add(new ImageView(new Image("/sample/foto/success.png")));
    else if (titulli == "Informacion")
        root.getChildren().add(new ImageView(new Image("/sample/foto/question.png")));
    else if (titulli == "Info")
        root.getChildren().add(new ImageView(new Image("/sample/foto/info.png")));
    root.getChildren().add(sub_root);
    root.setAlignment(Pos.TOP_CENTER);
    Scene scene = new Scene(root, 450, 150);
    scene.getStylesheets().add(getClass().getResource("/sample/style.css").toExternalForm());
    btnOk.isFocused();
    stage.setScene(scene);
    stage.show();
}
 
开发者ID:urankajtazaj,项目名称:Automekanik,代码行数:44,代码来源:Mesazhi.java


注:本文中的javafx.scene.control.Button.setOnAction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。