Example usage for javafx.scene.control Button setText

List of usage examples for javafx.scene.control Button setText

Introduction

In this page you can find the example usage for javafx.scene.control Button setText.

Prototype

public final void setText(String value) 

Source Link

Usage

From source file:fruitproject.FruitProject.java

public void first(final Stage primaryStage) {
    GridPane grid = new GridPane();
    grid.setAlignment(Pos.CENTER);//from  w w  w.  ja v  a2s . co  m
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(25, 25, 25, 25));

    rows = 0;
    addPairs.clear();

    Text lb = new Text();
    lb.setText("J-Fruit");
    //lb.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));
    grid.add(lb, 1, 0);

    final ToggleGroup grp = new ToggleGroup();
    RadioButton rb1 = new RadioButton();
    rb1.setText("Add Fruit file");
    rb1.setUserData("add");
    rb1.setToggleGroup(grp);
    rb1.setSelected(true);
    grid.add(rb1, 1, 1);

    RadioButton rb2 = new RadioButton();
    rb2.setText("Load Fruit file");
    rb2.setUserData("load");
    rb2.setToggleGroup(grp);
    grid.add(rb2, 1, 2);

    Label label1 = new Label("Enter File Name:");
    final TextField tfFilename = new TextField();
    final HBox hb = new HBox();
    hb.getChildren().addAll(label1, tfFilename);
    hb.setSpacing(10);
    hb.setVisible(false);
    tfFilename.setText("");
    grid.add(hb, 1, 3);

    grp.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
        public void changed(ObservableValue<? extends Toggle> ov, Toggle old_toggle, Toggle new_toggle) {
            if (grp.getSelectedToggle() != null) {
                // System.out.println(grp.getSelectedToggle().getUserData().toString());
                if (grp.getSelectedToggle().getUserData().toString() == "load")
                    hb.setVisible(true);
                else {
                    hb.setVisible(false);
                    tfFilename.setText("");
                }
            }
        }
    });

    if (rb2.isSelected() == true) {
        hb.setVisible(true);
    }

    Button btn = new Button();
    btn.setText("GO");
    grid.add(btn, 1, 4);
    btn.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            //System.out.println("Hello World!");
            if (tfFilename.getText() == "")
                second("");
            else
                second(tfFilename.getText());
            primaryStage.close();
        }
    });

    //StackPane root = new StackPane();
    //root.getChildren().add(lb);
    //root.getChildren().add(rb1);
    //root.getChildren().add(rb2);
    //root.getChildren().add(btn);

    Scene scene = new Scene(grid, 400, 450);
    primaryStage.setTitle("Hello World!");
    primaryStage.setScene(scene);
    primaryStage.show();

}

From source file:ca.wumbo.doommanager.client.controller.FileEditorController.java

@FXML
private void initialize() {
    // We only want the user to close the selected tab, not accidentally other tabs.
    fileTabPane.setTabClosingPolicy(TabClosingPolicy.SELECTED_TAB); // TODO - this should be configurable though as a user option.

    // We'll remove the text since its not needed (only useful in the SceneBuilder).
    for (Node node : toolbar.getItems()) {
        if (node instanceof Button) {
            Button button = (Button) node;
            button.setText("");
        }//w  ww .j  a v  a2  s .  c  om
    }

    // Set menu item graphics.
    newMenu.setGraphic(new ImageView(resources.getImage("newfile")));
    newWadMenuItem.setGraphic(new ImageView(resources.getImage("wadentry")));
    newPK3MenuItem.setGraphic(new ImageView(resources.getImage("pk3entry")));
    newDXMLProjectMenuItem.setGraphic(new ImageView(resources.getImage("dxmlprojectentry")));
    openFileMenuItem.setGraphic(new ImageView(resources.getImage("folder")));
    connectFileMenuItem.setGraphic(new ImageView(resources.getImage("network")));
    exitMenuItem.setGraphic(new ImageView(resources.getImage("close")));

    // Set button graphics.
    newWadButton.setGraphic(new ImageView(resources.getImage("newfile")));
    openFileButton.setGraphic(new ImageView(resources.getImage("folder")));
    connectButton.setGraphic(new ImageView(resources.getImage("network")));
    taskManagerButton.setGraphic(new ImageView(resources.getImage("taskmanager")));
}

From source file:com.github.drbookings.ui.controller.BookingDetailsController.java

private void addModifyButton(final VBox box, final BookingBean be) {
    final Button b = new Button();
    b.setText("Modify");
    b.setPrefWidth(100);//from  w  w w  .  j a v  a2  s.  co m
    b.setOnAction(e -> {
        if (modifyBookingDialogFactory == null) {
            modifyBookingDialogFactory = new ModifyBookingDialogFactory(getManager());
        }
        modifyBookingDialogFactory.showDialog();
    });
    box.getChildren().add(b);

}

From source file:fruitproject.FruitProject.java

public void second(final String pfname) {

    final Stage st = new Stage();
    Scene scene = null;/*www. j  a  va  2  s  .  co  m*/
    final GridPane grid = new GridPane();
    grid.setAlignment(Pos.CENTER);
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(25, 25, 25, 25));
    TableView tv = new TableView();

    final TableColumn<Map, String> firstDataColumn = new TableColumn<>("Name");
    final TableColumn<Map, String> secondDataColumn = new TableColumn<>("Amount");
    final TableColumn<Map, String> thirdDataColumn = new TableColumn<>("Remove");
    firstDataColumn.setMinWidth(130);
    secondDataColumn.setMinWidth(130);
    thirdDataColumn.setMinWidth(130);

    if (!pfname.equals("")) {

        firstDataColumn.setCellValueFactory(new MapValueFactory(Column1MapKey));
        secondDataColumn.setCellValueFactory(new MapValueFactory(Column2MapKey));
        thirdDataColumn.setCellValueFactory(new MapValueFactory(Column3MapKey));

        rows = 0;
        tv = new TableView<>(generateDataInMap(pfname, addPairs));

    }

    tv.getColumns().setAll(firstDataColumn, secondDataColumn, thirdDataColumn);

    // secondDataColumn.setCellFactory(TextFieldTableCell.forTableColumn());

    ScrollPane sp = new ScrollPane();
    sp.setMinWidth(400);
    sp.setHbarPolicy(ScrollBarPolicy.NEVER);
    sp.setContent(tv);
    grid.add(sp, 0, 3);

    final ComboBox comboBox = new ComboBox();
    HBox hb1 = new HBox();
    comboBox.setValue("FILE");
    comboBox.getItems().addAll("Save this file", "Load a new file");
    Button btnOk = new Button();
    btnOk.setText("OK");
    hb1.getChildren().addAll(comboBox, btnOk);
    hb1.setSpacing(10);
    grid.add(hb1, 0, 1);

    Label label1 = new Label("Title:");
    final TextField tfFilename = new TextField();
    tfFilename.setText(getTitle(pfname));
    HBox hb = new HBox();
    hb.getChildren().addAll(label1, tfFilename);
    hb.setSpacing(10);
    grid.add(hb, 0, 2);

    final Stage ps = new Stage();
    final TableView tv1 = tv;
    btnOk.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            //System.out.println("Hello World!");

            if (comboBox.getValue().equals("Load a new file")) {
                first(ps);
                st.close();
            } else {
                PrintWriter pw = null;
                try {
                    pw = new PrintWriter("abc.json");
                    BufferedWriter bw = new BufferedWriter(new FileWriter(pfname, false));
                    bw.write("{title:\"" + tfFilename.getText() + "\"");
                    bw.write(",fruits:[");
                    for (int i = 0; i < rows; i++) {
                        bw.write("{name:\"" + String.valueOf(firstDataColumn.getCellData(i)) + "\",amount:"
                                + String.valueOf(secondDataColumn.getCellData(i)) + "}");
                        if (i != rows - 1)
                            bw.write(",");
                    }
                    bw.write("]}");

                    bw.close();

                } catch (Exception e) {
                    System.out.println(e.toString());
                }

            }
        }
    });

    Button btn = new Button();
    btn.setText("New Fruit");
    grid.add(btn, 1, 2);

    // TableView tv=new TableView();
    // TableColumn Col1 = new TableColumn("Name");
    // TableColumn Col2 = new TableColumn("Amount");
    // TableColumn Col3 = new TableColumn("Remove");
    // tv.getColumns().addAll(Col1, Col2, Col3);

    //sp.setFitToWidth(true);

    Image img = new Image("file:music.jpg");
    ImageView iv2 = new ImageView();
    iv2.setImage(img);
    iv2.setFitWidth(200);
    iv2.setPreserveRatio(true);
    iv2.setSmooth(true);
    iv2.setCache(true);
    grid.add(iv2, 1, 3);

    btn.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            //System.out.println("Hello World!");

            System.out.println(comboBox.valueProperty());
            st.close();
            third(pfname);

        }
    });

    scene = new Scene(grid, 700, 450);
    st.setScene(scene);
    st.show();

}

From source file:de.ks.text.AsciiDocEditor.java

private void addCommands() {
    editorCommands.forEach(c -> {// w  ww. j a  va 2  s  .  c  o  m
        Button button = new Button();
        button.setMnemonicParsing(true);
        button.focusedProperty().addListener((p, o, n) -> {
            if (n) {
                focusOnEditor = false;
            }
        });
        c.initialize(this, button);
        this.commands.put(c.getClass(), c);
        button.setText(Localized.get(c.getName()));
        button.setOnAction(e -> c.execute(editor));
        editorCommandPane.getChildren().add(button);
    });
}

From source file:gov.va.isaac.sync.view.SyncView.java

private void initGui() {
    root_ = new BorderPane();
    root_.setPrefWidth(550);/* w w  w  .java 2s. c  o m*/

    VBox titleBox = new VBox();

    Label title = new Label("Datastore Synchronization");
    title.getStyleClass().add("titleLabel");
    title.setAlignment(Pos.CENTER);
    title.setMaxWidth(Double.MAX_VALUE);
    title.setPadding(new Insets(10));
    titleBox.getChildren().add(title);
    titleBox.getStyleClass().add("headerBackground");

    url_ = AppContext.getAppConfiguration().getCurrentChangeSetUrl();
    String urlType = AppContext.getAppConfiguration().getChangeSetUrlTypeName();

    String syncUsername = ExtendedAppContext.getCurrentlyLoggedInUserProfile().getSyncUsername();
    if (StringUtils.isBlank(syncUsername)) {
        syncUsername = ExtendedAppContext.getCurrentlyLoggedInUser();
    }

    url_ = syncService_.substituteURL(url_, syncUsername);

    Label info = new CopyableLabel("Sync using " + urlType + ": " + url_);
    info.setTooltip(new Tooltip(url_));

    titleBox.getChildren().add(info);

    titleBox.setPadding(new Insets(5, 5, 5, 5));
    root_.setTop(titleBox);

    VBox centerContent = new VBox();
    centerContent.setFillWidth(true);
    centerContent.setPrefWidth(Double.MAX_VALUE);
    centerContent.setPadding(new Insets(10));
    centerContent.getStyleClass().add("itemBorder");
    centerContent.setSpacing(10.0);

    centerContent.getChildren().add(new Label("Status:"));

    summary_ = new TextArea();
    summary_.setWrapText(true);
    summary_.setEditable(false);
    summary_.setMaxWidth(Double.MAX_VALUE);
    summary_.setMaxHeight(Double.MAX_VALUE);
    summary_.setPrefHeight(150.0);

    centerContent.getChildren().add(summary_);
    VBox.setVgrow(summary_, Priority.ALWAYS);

    pb_ = new ProgressBar(0.0);
    pb_.setPrefHeight(20);
    pb_.setMaxWidth(Double.MAX_VALUE);

    centerContent.getChildren().add(pb_);

    root_.setCenter(centerContent);

    //Bottom buttons
    HBox buttons = new HBox();
    buttons.setMaxWidth(Double.MAX_VALUE);
    buttons.setAlignment(Pos.CENTER);
    buttons.setPadding(new Insets(5));
    buttons.setSpacing(30);

    Button cancel = new Button("Close");
    cancel.setOnAction((action) -> {
        if (running_.get()) {
            addLine("Cancelling...");
            cancel.setDisable(true);
            cancelRequested_ = true;
        } else {
            cancel.getScene().getWindow().hide();
            root_ = null;
        }
    });
    buttons.getChildren().add(cancel);

    Button action = new Button("Synchronize");
    action.disableProperty().bind(running_);
    action.setOnAction((theAction) -> {
        summary_.setText("");
        pb_.setProgress(-1.0);
        running_.set(true);
        Utility.execute(() -> sync());
    });
    buttons.getChildren().add(action);

    cancel.minWidthProperty().bind(action.widthProperty());

    running_.addListener(change -> {
        if (running_.get()) {
            cancel.setText("Cancel");
        } else {
            cancel.setText("Close");
        }
        cancel.setDisable(false);
    });

    root_.setBottom(buttons);
}

From source file:MediaControl.java

public MediaControl(final MediaPlayer mp) {
    this.mp = mp;
    setStyle("-fx-background-color: #bfc2c7;");
    mediaView = new MediaView(mp);
    Pane mvPane = new Pane() {
    };/*from  w ww  .j av  a  2  s. c om*/
    mvPane.getChildren().add(mediaView);
    mvPane.setStyle("-fx-background-color: black;");
    setCenter(mvPane);
    mediaBar = new HBox();
    mediaBar.setAlignment(Pos.CENTER);
    mediaBar.setPadding(new Insets(5, 10, 5, 10));
    BorderPane.setAlignment(mediaBar, Pos.CENTER);

    final Button playButton = new Button(">");

    playButton.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent e) {
            Status status = mp.getStatus();

            if (status == Status.UNKNOWN || status == Status.HALTED) {
                // don't do anything in these states
                return;
            }

            if (status == Status.PAUSED || status == Status.READY || status == Status.STOPPED) {
                // rewind the movie if we're sitting at the end
                if (atEndOfMedia) {
                    mp.seek(mp.getStartTime());
                    atEndOfMedia = false;
                }
                mp.play();
            } else {
                mp.pause();
            }
        }
    });
    mp.currentTimeProperty().addListener(new InvalidationListener() {
        public void invalidated(Observable ov) {
            updateValues();
        }
    });

    mp.setOnPlaying(new Runnable() {
        public void run() {
            if (stopRequested) {
                mp.pause();
                stopRequested = false;
            } else {
                playButton.setText("||");
            }
        }
    });

    mp.setOnPaused(new Runnable() {
        public void run() {
            System.out.println("onPaused");
            playButton.setText(">");
        }
    });

    mp.setOnReady(new Runnable() {
        public void run() {
            duration = mp.getMedia().getDuration();
            updateValues();
        }
    });

    mp.setCycleCount(repeat ? MediaPlayer.INDEFINITE : 1);
    mp.setOnEndOfMedia(new Runnable() {
        public void run() {
            if (!repeat) {
                playButton.setText(">");
                stopRequested = true;
                atEndOfMedia = true;
            }
        }
    });
    mediaBar.getChildren().add(playButton);
    // Add spacer
    Label spacer = new Label("   ");
    mediaBar.getChildren().add(spacer);

    // Add Time label
    Label timeLabel = new Label("Time: ");
    mediaBar.getChildren().add(timeLabel);

    // Add time slider
    timeSlider = new Slider();
    HBox.setHgrow(timeSlider, Priority.ALWAYS);
    timeSlider.setMinWidth(50);
    timeSlider.setMaxWidth(Double.MAX_VALUE);

    timeSlider.valueProperty().addListener(new InvalidationListener() {
        public void invalidated(Observable ov) {
            if (timeSlider.isValueChanging()) {
                // multiply duration by percentage calculated by slider position
                mp.seek(duration.multiply(timeSlider.getValue() / 100.0));
            }
        }
    });

    mediaBar.getChildren().add(timeSlider);

    // Add Play label
    playTime = new Label();
    playTime.setPrefWidth(130);
    playTime.setMinWidth(50);
    mediaBar.getChildren().add(playTime);

    // Add the volume label
    Label volumeLabel = new Label("Vol: ");
    mediaBar.getChildren().add(volumeLabel);

    // Add Volume slider
    volumeSlider = new Slider();
    volumeSlider.setPrefWidth(70);
    volumeSlider.setMaxWidth(Region.USE_PREF_SIZE);
    volumeSlider.setMinWidth(30);
    volumeSlider.valueProperty().addListener(new InvalidationListener() {
        public void invalidated(Observable ov) {
            if (volumeSlider.isValueChanging()) {
                mp.setVolume(volumeSlider.getValue() / 100.0);
            }
        }
    });
    mediaBar.getChildren().add(volumeSlider);
    setBottom(mediaBar);
}

From source file:patientmanagerv1.HomeController.java

public void printAdv() {
    final Stage dialog = new Stage();
    dialog.initModality(Modality.APPLICATION_MODAL);

    final TextField textField = new TextField();
    Button submit = new Button();
    Button cancel = new Button();
    final Label label = new Label();

    cancel.setText("Cancel");
    cancel.setAlignment(Pos.CENTER);//  w  w w . j  a va  2 s.c o  m
    submit.setText("Submit");
    submit.setAlignment(Pos.BOTTOM_RIGHT);

    final VBox dialogVbox = new VBox(20);
    dialogVbox.getChildren().add(new Text("Enter the master password: "));
    dialogVbox.getChildren().add(textField);
    dialogVbox.getChildren().add(submit);
    dialogVbox.getChildren().add(cancel);
    dialogVbox.getChildren().add(label);

    Scene dialogScene = new Scene(dialogVbox, 300, 200);
    dialog.setScene(dialogScene);
    dialog.setTitle("Security/Physician Authentication");
    dialog.show();

    submit.setOnAction(new EventHandler<ActionEvent>() {

        public void handle(ActionEvent anEvent) {
            String password = textField.getText();

            if (password.equalsIgnoreCase("protooncogene")) {
                dialog.close();

                writeEvalToDocX(false, "");

                //OPENS the document for printing:
                try {
                    if (Desktop.isDesktopSupported()) {
                        Desktop.getDesktop()
                                .open(new File(installationPath + "/userdata/" + firstName + lastName + dob
                                        + "/" + firstName + lastName + dob + "psychiatricevaluation.docx"));
                    }
                } catch (IOException ioe) {
                    ioe.printStackTrace();
                }
            } else {
                label.setText("The password you entered is incorrect. Please try again.");
            }

            //adds files to file tracker

        }
    });

    cancel.setOnAction(new EventHandler<ActionEvent>() {

        public void handle(ActionEvent anEvent) {
            dialog.close();
            //close the window here
        }
    });

}

From source file:patientmanagerv1.HomeController.java

public void assistantSign() {
    final Stage dialog = new Stage();
    dialog.initModality(Modality.APPLICATION_MODAL);

    final TextField textField = new TextField();
    Button submit = new Button();
    Button cancel = new Button();
    final Label label = new Label();

    cancel.setText("Cancel");
    cancel.setAlignment(Pos.CENTER);/*w  w  w  .  ja  v a  2s .  c  om*/
    submit.setText("Submit");
    submit.setAlignment(Pos.BOTTOM_RIGHT);

    final VBox dialogVbox = new VBox(20);
    dialogVbox.getChildren().add(new Text("Please enter the physician's assistant password: "));
    dialogVbox.getChildren().add(textField);
    dialogVbox.getChildren().add(submit);
    dialogVbox.getChildren().add(cancel);
    dialogVbox.getChildren().add(label);

    Scene dialogScene = new Scene(dialogVbox, 300, 200);
    dialog.setScene(dialogScene);
    dialog.setTitle("Security/Physician's Assistant Authentication");
    dialog.show();

    submit.setOnAction(new EventHandler<ActionEvent>() {

        public void handle(ActionEvent anEvent) {
            String password = textField.getText();

            if (password.equalsIgnoreCase("siberianplatypus")) {
                partnerSigned = true;

                dialog.close();

                assistantsign.setVisible(false);
                saveButton.setDisable(true);
                //signature.setText("This document has been digitally signed by David Zhvikov MD");
                //signature.setVisible(true);
                //signature2.setVisible(true);
                assistantsignature.setVisible(true);

                //update the "signed" status document here, checked the "signed" status in the initialize() method and enable/disable the buttons and message accordingly onLoad...when the signed document is first created, it should be set to false (f) by default
                try {
                    File signedStatus = new File(installationPath + "/userdata/" + firstName.toLowerCase()
                            + lastName.toLowerCase() + dob + "/EvaluationForm/assistantsigned.txt");
                    FileWriter writ = new FileWriter(signedStatus, false); //it is set to false so that it (the current patient) will be overwritten every time
                    BufferedWriter bw = new BufferedWriter(writ);
                    writ.append("true");
                    bw.close();
                    writ.close();
                } catch (IOException e) {
                }

                ap.setDisable(true);

                //System.out.println(engaged.isSelected());
            } else {
                label.setText("The password you entered is incorrect. Please try again.");
            }

            //adds files to file tracker

        }
    });

    cancel.setOnAction(new EventHandler<ActionEvent>() {

        public void handle(ActionEvent anEvent) {
            dialog.close();
            //close the window here
        }
    });
}

From source file:patientmanagerv1.HomeController.java

public void signEvaluation() {
    final Stage dialog = new Stage();
    dialog.initModality(Modality.APPLICATION_MODAL);

    final TextField textField = new TextField();
    Button submit = new Button();
    Button cancel = new Button();
    final Label label = new Label();

    cancel.setText("Cancel");
    cancel.setAlignment(Pos.CENTER);/*from   ww  w .  ja  v  a 2s .c o m*/
    submit.setText("Submit");
    submit.setAlignment(Pos.BOTTOM_RIGHT);

    final VBox dialogVbox = new VBox(20);
    dialogVbox.getChildren()
            .add(new Text("Only the physician can sign this document. Please enter the master password: "));
    dialogVbox.getChildren().add(textField);
    dialogVbox.getChildren().add(submit);
    dialogVbox.getChildren().add(cancel);
    dialogVbox.getChildren().add(label);

    Scene dialogScene = new Scene(dialogVbox, 300, 200);
    dialog.setScene(dialogScene);
    dialog.setTitle("Security/Physician Authentication");
    dialog.show();

    submit.setOnAction(new EventHandler<ActionEvent>() {

        public void handle(ActionEvent anEvent) {
            String password = textField.getText();

            if (password.equalsIgnoreCase("protooncogene")) {
                dccSigned = true;

                dialog.close();

                sign.setVisible(false);
                saveButton.setDisable(true);
                signature.setText("This document has been digitally signed by David Zhvikov MD");
                signature.setVisible(true);
                signature2.setVisible(true);

                //update the "signed" status document here, checked the "signed" status in the initialize() method and enable/disable the buttons and message accordingly onLoad...when the signed document is first created, it should be set to false (f) by default
                try {
                    File signedStatus = new File(installationPath + "/userdata/" + firstName.toLowerCase()
                            + lastName.toLowerCase() + dob + "/EvaluationForm/signed.txt");
                    FileWriter writ = new FileWriter(signedStatus, false); //it is set to false so that it (the current patient) will be overwritten every time
                    BufferedWriter bw = new BufferedWriter(writ);
                    writ.append("true");
                    bw.close();
                    writ.close();
                } catch (IOException e) {
                }

                ap.setDisable(true);

                //System.out.println(engaged.isSelected());
            } else {
                label.setText("The password you entered is incorrect. Please try again.");
            }

            //adds files to file tracker

        }
    });

    cancel.setOnAction(new EventHandler<ActionEvent>() {

        public void handle(ActionEvent anEvent) {
            dialog.close();
            //close the window here
        }
    });

    //"save as document" (exporting) should become enabled after signing? (ask dcc if he wants this) --> it should automatically convert the generated word document to a pdf
}