Example usage for javafx.scene.text Text Text

List of usage examples for javafx.scene.text Text Text

Introduction

In this page you can find the example usage for javafx.scene.text Text Text.

Prototype

public Text(String text) 

Source Link

Document

Creates an instance of Text containing the given string.

Usage

From source file:UI.MainPageController.java

/**
 * Popup dialog box that display the string passed in
 * @param warning //from  w  w  w.  j  av a 2 s  . c  o  m
 */
private void showWarning(String warning) {
    Stage popup = new Stage();
    VBox headsUp = new VBox();
    Text prompt = new Text(warning);
    prompt.setStyle("-fx-font-size: 11pt;");
    headsUp.getChildren().add(prompt);
    headsUp.setAlignment(Pos.CENTER);
    popup.setScene(new Scene(headsUp, 300, 200));
    popup.setTitle("Warning");
    popup.show();
}

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

private static void addGeneralSummary(final LocalDate date, final VBox box,
        final List<CheckInOutDetails> checkInNotes) {
    final Text t0 = new Text(getDateString(date));
    final Text t1 = new Text(", there " + (checkInNotes.size() > 1 ? " are " : "is "));
    t0.getStyleClass().add("emphasis");
    final TextFlow tf = new TextFlow();
    tf.getChildren().addAll(t0, t1);//  w w w. j av a2  s  .c  o m
    box.getChildren().add(tf);
}

From source file:statos2_0.StatOS2_0.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("");

    GridPane root = new GridPane();
    Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize();
    root.setAlignment(Pos.CENTER);/*from   ww w  .  j ava 2 s .  co  m*/
    root.setHgap(10);
    root.setVgap(10);
    root.setPadding(new Insets(25, 25, 25, 25));

    Text scenetitle = new Text("");

    root.add(scenetitle, 0, 0, 2, 1);
    scenetitle.setId("welcome-text");
    Label userName = new Label(":");
    //userName.setId("label");
    root.add(userName, 0, 1);

    TextField userTextField = new TextField();
    root.add(userTextField, 1, 1);

    Label pw = new Label(":");
    root.add(pw, 0, 2);

    PasswordField pwBox = new PasswordField();
    root.add(pwBox, 1, 2);
    ComboBox store = new ComboBox();
    store.setItems(GetByTag());
    root.add(store, 1, 3);

    Button btn = new Button("");
    //btn.setPrefSize(100, 20);
    HBox hbBtn = new HBox(10);
    hbBtn.setAlignment(Pos.BOTTOM_RIGHT);
    hbBtn.getChildren().add(btn);

    root.add(hbBtn, 1, 4);

    Button btn2 = new Button("");
    //btn2.setPrefSize(100, 20);
    HBox hbBtn2 = new HBox(10);
    hbBtn2.setAlignment(Pos.BOTTOM_RIGHT);
    hbBtn2.getChildren().add(btn2);
    root.add(hbBtn2, 1, 5);

    final Text actiontarget = new Text();
    root.add(actiontarget, 1, 6);

    btn2.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent e) {
            System.exit(0);
        }
    });

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

        @Override
        public void handle(ActionEvent e) {
            if (userTextField.getText().equals("")) {
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("!");
                alert.setHeaderText("!");
                alert.setContentText("   !");
                alert.showAndWait();
            } else if (pwBox.getText().equals("")) {
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("!");
                alert.setHeaderText("!");
                alert.setContentText("   !");
                alert.showAndWait();
            } else if (store.getSelectionModel().getSelectedIndex() < 0) {
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("!");
                alert.setHeaderText("!");
                alert.setContentText("   !");
                alert.showAndWait();
            } else {
                try {
                    String[] resu = checkpas(userTextField.getText(), pwBox.getText());
                    if (resu[0].equals("-1")) {
                        Alert alert = new Alert(Alert.AlertType.ERROR);
                        alert.setTitle("!");
                        alert.setHeaderText("!");
                        alert.setContentText("   !");
                        alert.showAndWait();
                    } else if (storecheck((store.getSelectionModel().getSelectedIndex() + 1)) == false) {
                        Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
                        alert.setTitle("!");
                        alert.setHeaderText("!");
                        alert.setContentText("     !"
                                + "\n       -  ");
                        Optional<ButtonType> result = alert.showAndWait();
                        if (result.get() == ButtonType.OK) {
                            // ... user chose OK
                            idstore = store.getSelectionModel().getSelectedIndex() + 1;
                            updsel(idstore, Integer.parseInt(resu[0]));
                            MainA ma = new MainA();
                            ma.m = (idstore);
                            ma.MT = "m" + idstore;
                            ma.selid = Integer.parseInt(resu[0]);
                            ma.nameseller = resu[1];
                            ma.storename = store.getSelectionModel().getSelectedItem().toString();
                            ma.start(primaryStage);
                        } else {
                            // ... user chose CANCEL or closed the dialog
                        }

                    } else {
                        // 

                        idstore = store.getSelectionModel().getSelectedIndex() + 1;
                        updsel(idstore, Integer.parseInt(resu[0]));
                        MainA ma = new MainA();
                        ma.m = (idstore);
                        ma.MT = "m" + idstore;
                        ma.selid = Integer.parseInt(resu[0]);
                        ma.nameseller = resu[1];
                        ma.storename = store.getSelectionModel().getSelectedItem().toString();

                        ma.start(primaryStage);

                    }

                } catch (NoSuchAlgorithmException ex) {
                    Logger.getLogger(StatOS2_0.class.getName()).log(Level.SEVERE, null, ex);
                } catch (Exception ex) {
                    Logger.getLogger(StatOS2_0.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
            /**
             * if((userTextField.getText().equals("admin"))&(pwBox.getText().equals("admin"))){
             * actiontarget.setId("acttrue");
             * actiontarget.setText(" !");
             * MainA ma = new MainA();
             * ma.m=1;
             * try {
             * ma.m=1;
             * ma.MT="m1";
             * ma.start(primaryStage);
             * } catch (Exception ex) {
             * Logger.getLogger(StatOS2_0.class.getName()).log(Level.SEVERE, null, ex);
             * }
             * }else{
             * actiontarget.setId("actfalse");
             * actiontarget.setText(" !");
             * } **/

        }
    });
    //Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize();
    //sSize.getHeight();
    Scene scene = new Scene(root, sSize.getWidth(), sSize.getHeight());

    primaryStage.setScene(scene);
    scene.getStylesheets().add(StatOS2_0.class.getResource("adminStatOS.css").toExternalForm());
    primaryStage.show();
}

From source file:Main.java

private GridPane addGridPane() {

    GridPane grid = new GridPane();
    grid.setHgap(10);/* w ww .j a  v  a2 s  .c o m*/
    grid.setVgap(10);
    grid.setPadding(new Insets(0, 10, 0, 10));

    // Category in column 2, row 1
    Text category = new Text("Sales:");
    category.setFont(Font.font("Arial", FontWeight.BOLD, 20));
    grid.add(category, 1, 0);

    // Title in column 3, row 1
    Text chartTitle = new Text("Current Year");
    chartTitle.setFont(Font.font("Arial", FontWeight.BOLD, 20));
    grid.add(chartTitle, 2, 0);

    // Subtitle in columns 2-3, row 2
    Text chartSubtitle = new Text("Goods and Services");
    grid.add(chartSubtitle, 1, 1, 2, 1);

    // House icon in column 1, rows 1-2
    ImageView imageHouse = new ImageView(new Image(Main.class.getResourceAsStream("graphics/house.png")));
    grid.add(imageHouse, 0, 0, 1, 2);

    // Left label in column 1 (bottom), row 3
    Text goodsPercent = new Text("Goods\n80%");
    GridPane.setValignment(goodsPercent, VPos.BOTTOM);
    grid.add(goodsPercent, 0, 2);

    // Chart in columns 2-3, row 3
    ImageView imageChart = new ImageView(new Image(Main.class.getResourceAsStream("graphics/piechart.png")));
    grid.add(imageChart, 1, 2, 2, 1);

    // Right label in column 4 (top), row 3
    Text servicesPercent = new Text("Services\n20%");
    GridPane.setValignment(servicesPercent, VPos.TOP);
    grid.add(servicesPercent, 3, 2);

    //        grid.setGridLinesVisible(true);
    return grid;
}

From source file:FeeBooster.java

private GridPane rbfGrid(Transaction tx) {
    // Setup grid
    GridPane grid = new GridPane();
    grid.setAlignment(Pos.CENTER);/*w ww . j  a v  a 2s. c om*/
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(25, 25, 25, 25));
    int inGridHeight = 0;
    int outGridHeight = 0;

    // Add inputs to table
    Label inputHdrLbl = new Label("Inputs");
    grid.add(inputHdrLbl, 0, inGridHeight);
    inGridHeight++;
    for (int i = 0; i < tx.getInputs().size(); i++) {
        // Add input to table
        TxInput in = tx.getInputs().get(i);
        Text inputTxt = new Text("Txid: " + in.getTxid() + "\nIndex: " + in.getVout());
        grid.add(inputTxt, 0, inGridHeight);
        inGridHeight++;
    }

    // Add outputs to table
    Label outputHdrLbl = new Label("Outputs");
    grid.add(outputHdrLbl, 1, outGridHeight);
    outGridHeight++;
    ToggleGroup outputGroup = new ToggleGroup();
    for (int i = 0; i < tx.getOutputs().size(); i++) {
        // Add output to table
        TxOutput out = tx.getOutputs().get(i);
        Text outputTxt = new Text("Amount " + out.getValue() + " Satoshis\nAddress: " + out.getAddress());
        outputTxt.setUserData(i);
        grid.add(outputTxt, 1, outGridHeight);

        // Add radio button to table
        RadioButton radio = new RadioButton();
        radio.setUserData(i);
        radio.setToggleGroup(outputGroup);
        radio.setSelected(true);
        grid.add(radio, 2, outGridHeight);
        outGridHeight++;
    }

    // Set gridheight
    int gridheight = (inGridHeight < outGridHeight) ? outGridHeight : inGridHeight;
    gridheight++;

    // Fee
    Text fee = new Text("Fee Paid: " + tx.getFee() + " Satoshis");
    grid.add(fee, 0, gridheight);

    // Recommended fee from bitcoinfees.21.co
    JSONObject apiResult = Utils.getFromAnAPI("http://bitcoinfees.21.co/api/v1/fees/recommended", "GET");
    int fastestFee = apiResult.getInt("fastestFee");
    long recommendedFee = fastestFee * tx.getSize();
    Text recFeeTxt = new Text("Recommended Fee: " + recommendedFee + " Satoshis");
    grid.add(recFeeTxt, 1, gridheight);
    gridheight += 2;

    // Instructions
    Text instructions = new Text(
            "Choose an output to deduct an additional fee from. Then increase the fee below.");
    grid.add(instructions, 0, gridheight, 3, 1);
    gridheight++;

    // Fee spinner
    Spinner feeSpin = new Spinner((double) tx.getFee(), (double) tx.getTotalAmt(), (double) tx.getFee());
    feeSpin.setEditable(true);
    grid.add(feeSpin, 0, gridheight);
    feeSpin.valueProperty().addListener(new ChangeListener() {
        @Override
        public void changed(ObservableValue observable, Object oldValue, Object newValue) {
            double oldVal = (double) oldValue;
            double newVal = (double) newValue;
            Double step = newVal - oldVal;
            tx.setFee(tx.getFee() + step.longValue());
            fee.setText("Fee Paid: " + tx.getFee() + " Satoshis");
            int output = (int) outputGroup.getSelectedToggle().getUserData();
            TxOutput out = tx.getOutputs().get(output);
            out.decreaseValueBy(step.longValue());
            for (int i = 0; i < grid.getChildren().size(); i++) {
                Node child = grid.getChildren().get(i);
                if (grid.getRowIndex(child) == output + 1 && grid.getColumnIndex(child) == 1) {
                    ((Text) child)
                            .setText("Amount " + out.getValue() + " Satoshis\nAddress: " + out.getAddress());
                }
            }
        }
    });

    // Set to recommended fee button
    Button recFeeBtn = new Button("Set fee to recommended");
    grid.add(recFeeBtn, 1, gridheight);
    gridheight++;
    recFeeBtn.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            long prevFee = tx.getFee();
            long step = recommendedFee - prevFee;
            feeSpin.increment((int) step);
        }
    });

    // Next Button
    Button nextBtn = new Button("Next");
    grid.add(nextBtn, 1, gridheight);
    nextBtn.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            if (sceneCursor == scenes.size() - 1) {
                Scene scene = new Scene(unsignedTxGrid(tx), 900, 500);
                scenes.add(scene);
                sceneCursor++;
                stage.setScene(scene);
            } else {
                sceneCursor++;
                stage.setScene(scenes.get(sceneCursor));
            }
        }
    });
    HBox btnHbox = new HBox(10);

    // Back Button
    Button backBtn = new Button("Back");
    backBtn.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            sceneCursor--;
            stage.setScene(scenes.get(sceneCursor));
        }
    });
    btnHbox.getChildren().add(backBtn);
    btnHbox.getChildren().add(nextBtn);

    // Cancel Button
    Button cancelBtn = new Button("Cancel");
    cancelBtn.setOnAction(cancelEvent);
    btnHbox.getChildren().add(cancelBtn);
    grid.add(btnHbox, 1, gridheight);

    return grid;
}

From source file:net.sourceforge.pmd.util.fxdesigner.XPathPanelController.java

private static TextFlow highlightXPathSuggestion(String text, String match) {
    int filterIndex = text.toLowerCase(Locale.ROOT).indexOf(match.toLowerCase(Locale.ROOT));

    Text textBefore = new Text(text.substring(0, filterIndex));
    Text textAfter = new Text(text.substring(filterIndex + match.length()));
    Text textFilter = new Text(text.substring(filterIndex, filterIndex + match.length())); //instead of "filter" to keep all "case sensitive"
    textFilter.setFill(Color.ORANGE);
    return new TextFlow(textBefore, textFilter, textAfter);
}

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

private void addCheckInNote(final Pane content, final BookingBean be) {
    final VBox b = new VBox();
    b.getChildren().add(new Text("Check-in Note"));
    final TextArea ta0 = new TextArea(be.getCheckInNote());
    ta0.setWrapText(true);/*from w w  w . ja v a 2s  .  c o m*/
    ta0.setPrefHeight(80);
    b.getChildren().add(ta0);
    booking2CheckInNote.put(be, ta0);
    content.getChildren().add(b);

}

From source file:Testing.TestMain.java

public static void grid(Stage stage) {
    GridPane grid = new GridPane();
    grid.setHgap(8);/*from  w  ww .ja va2s  .  com*/
    grid.setVgap(8);
    grid.setPadding(new Insets(5));

    Text mp3FileNameT, trackNoT, titleT, artistsT, lengthT, albumT, yearT, genreT, commentsT;

    mp3FileNameT = new Text("Filename:");
    trackNoT = new Text("Track Number:");
    titleT = new Text("Title:");
    artistsT = new Text("Artists:");
    lengthT = new Text("Track Length:");
    albumT = new Text("Album:");
    yearT = new Text("Year:");
    genreT = new Text("Genere:");
    commentsT = new Text("Comments/Lyrics: ");

    TextField mp3FileNameTF, trackNoTF, titleTF, artistsTF, lengthTF, albumTF, yearTF, genreTF;
    TextArea commentsTF;

    mp3FileNameTF = new TextField("");
    trackNoTF = new TextField("");
    titleTF = new TextField("");
    artistsTF = new TextField("");
    lengthTF = new TextField("");
    albumTF = new TextField("");
    yearTF = new TextField("");
    genreTF = new TextField("");
    commentsTF = new TextArea("");

    grid.addColumn(0, mp3FileNameT, trackNoT, titleT, artistsT, lengthT, albumT, yearT, genreT, commentsT);
    grid.addColumn(1, mp3FileNameTF, trackNoTF, titleTF, artistsTF, lengthTF, albumTF, yearTF, genreTF,
            commentsTF);
    grid.setAlignment(Pos.TOP_LEFT);
    Scene scene = new Scene(grid, 500, 500);

    stage.setTitle("Grid Test");
    stage.setScene(scene);
    stage.show();
}

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

private void addCheckOutNote(final Pane content, final BookingBean be) {
    final VBox b = new VBox();
    b.getChildren().add(new Text("Check-out Note"));
    final TextArea ta0 = new TextArea(be.getCheckOutNote());
    ta0.setWrapText(true);/*w  ww  .  j  a v a2 s  . com*/
    ta0.setPrefHeight(80);
    b.getChildren().add(ta0);
    booking2CheckOutNote.put(be, ta0);
    content.getChildren().add(b);

}

From source file:de.pixida.logtest.designer.logreader.LogReaderEditor.java

public VBox createRunForm() {
    // CHECKSTYLE:OFF Yes, we are using lots of constants here. It does not make sense to name them using final variables.
    final VBox lines = new VBox();
    lines.setSpacing(10d);//from  w w  w.java  2s  . com
    final HBox inputTypeLine = new HBox();
    inputTypeLine.setSpacing(30d);
    final ToggleGroup group = new ToggleGroup();
    final RadioButton inputTypeText = new RadioButton("Paste/Enter text");
    inputTypeText.setToggleGroup(group);
    final RadioButton inputTypeFile = new RadioButton("Read log file");
    inputTypeFile.setToggleGroup(group);
    inputTypeLine.getChildren().add(inputTypeText);
    inputTypeLine.getChildren().add(inputTypeFile);
    inputTypeText.setSelected(true);
    final TextField pathInput = new TextField();
    HBox.setHgrow(pathInput, Priority.ALWAYS);
    final Button selectLogFileButton = SelectFileButton.createButtonWithFileSelection(pathInput,
            LOG_FILE_ICON_NAME, "Select log file", null, null);
    final Text pathInputLabel = new Text("Log file path: ");
    final HBox fileInputConfig = new HBox();
    fileInputConfig.setAlignment(Pos.CENTER_LEFT);
    fileInputConfig.visibleProperty().bind(inputTypeFile.selectedProperty());
    fileInputConfig.managedProperty().bind(fileInputConfig.visibleProperty());
    fileInputConfig.getChildren().addAll(pathInputLabel, pathInput, selectLogFileButton);
    final TextArea logInputText = new TextArea();
    HBox.setHgrow(logInputText, Priority.ALWAYS);
    logInputText.setPrefRowCount(10);
    logInputText.setStyle("-fx-font-family: monospace");
    final HBox enterTextConfig = new HBox();
    enterTextConfig.getChildren().add(logInputText);
    enterTextConfig.visibleProperty().bind(inputTypeText.selectedProperty());
    enterTextConfig.managedProperty().bind(enterTextConfig.visibleProperty());
    final Button startBtn = new Button("Read Log");
    startBtn.setPadding(new Insets(8d));
    // CHECKSTYLE:ON
    startBtn.setGraphic(Icons.getIconGraphics("control_play_blue"));
    HBox.setHgrow(startBtn, Priority.ALWAYS);
    startBtn.setMaxWidth(Double.MAX_VALUE);
    startBtn.setOnAction(event -> this.runLogFileReader(inputTypeFile, pathInput, logInputText));
    final HBox startLine = new HBox();
    startLine.getChildren().add(startBtn);
    lines.getChildren().addAll(inputTypeLine, fileInputConfig, enterTextConfig, startLine, new Text("Results:"),
            this.parsedLogEntries);
    return lines;
}