當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。