Example usage for javafx.scene.control Label Label

List of usage examples for javafx.scene.control Label Label

Introduction

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

Prototype

public Label(String text) 

Source Link

Document

Creates Label with supplied text.

Usage

From source file:projavafx.videoplayer3.VideoPlayer3.java

@Override
public void start(Stage primaryStage) {
    final Label message = new Label("I \u2764 Robots");
    message.setVisible(false);//from   w  w w . j  a v  a  2s .c o m

    String workingDir = System.getProperty("user.dir");
    final File f = new File(workingDir, "../media/omgrobots.flv");

    final Media m = new Media(f.toURI().toString());
    m.getMarkers().put("Split", Duration.millis(3000));
    m.getMarkers().put("Join", Duration.millis(9000));

    final MediaPlayer mp = new MediaPlayer(m);

    final MediaView mv1 = new MediaView(mp);
    mv1.setViewport(new Rectangle2D(0, 0, 960 / 2, 540));
    StackPane.setAlignment(mv1, Pos.CENTER_LEFT);

    final MediaView mv2 = new MediaView(mp);
    mv2.setViewport(new Rectangle2D(960 / 2, 0, 960 / 2, 540));
    StackPane.setAlignment(mv2, Pos.CENTER_RIGHT);

    StackPane root = new StackPane();
    root.getChildren().addAll(message, mv1, mv2);
    root.setOnMouseClicked(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent event) {
            mp.seek(Duration.ZERO);
            message.setVisible(false);
        }
    });

    final Scene scene = new Scene(root, 960, 540);
    final URL stylesheet = getClass().getResource("media.css");
    scene.getStylesheets().add(stylesheet.toString());

    primaryStage.setScene(scene);
    primaryStage.setTitle("Video Player 3");
    primaryStage.show();

    mp.setOnMarker(new EventHandler<MediaMarkerEvent>() {

        @Override
        public void handle(final MediaMarkerEvent event) {
            Platform.runLater(new Runnable() {

                @Override
                public void run() {
                    if (event.getMarker().getKey().equals("Split")) {
                        message.setVisible(true);
                        buildSplitTransition(mv1, mv2).play();
                    } else {
                        buildJoinTransition(mv1, mv2).play();
                    }
                }

            });
        }
    });
    mp.play();
}

From source file:org.pdfsam.alternatemix.AlternateMixOptionsPane.java

AlternateMixOptionsPane() {
    super(Style.DEFAULT_SPACING);
    this.reverseFirst.setId("reverseFirst");
    this.reverseSecond.setId("reverseSecond");
    this.reverseSecond.setSelected(true);
    this.firstStep.setId("alternateMixFirstStep");
    this.secondStep.setId("alternateMixSecondStep");
    initialState();//ww  w. j a  v a  2 s.c om
    getStyleClass().addAll(Style.CONTAINER.css());
    HBox firstStepContainer = new HBox(
            new Label(DefaultI18nContext.getInstance()
                    .i18n("Switch from the first document to the second one after the following pages")),
            firstStep);
    firstStepContainer.getStyleClass().addAll(Style.HCONTAINER.css());
    HBox secondStepContainer = new HBox(
            new Label(DefaultI18nContext.getInstance()
                    .i18n("Switch from the second document to the first one after the following pages")),
            secondStep);
    secondStepContainer.getStyleClass().addAll(Style.HCONTAINER.css());
    getChildren().addAll(this.reverseFirst, this.reverseSecond, firstStepContainer, secondStepContainer);
}

From source file:org.pdfsam.extract.ExtractOptionsPane.java

ExtractOptionsPane() {
    this.field.setOnEnterValidation(true);
    this.field.setEnableInvalidStyle(true);
    this.field.setPromptText(
            DefaultI18nContext.getInstance().i18n("Pages to extract (ex: 2 or 5-23 or 2,5-7,12-)"));
    this.field.setValidator(v -> {
        try {//ww w .j  a  va 2s .  c  o m
            return !toPageRangeSet(this.field.getText()).isEmpty();
        } catch (ConversionException e) {
            return false;
        }
    });
    this.field.setErrorMessage(DefaultI18nContext.getInstance().i18n("Invalid page ranges"));
    this.field.setId("extractRanges");
    this.field.setPrefWidth(350);
    getStyleClass().addAll(Style.CONTAINER.css());
    getStyleClass().addAll(Style.HCONTAINER.css());
    getChildren().addAll(new Label(DefaultI18nContext.getInstance().i18n("Extract pages:")), this.field,
            helpIcon("Comma separated page numbers or ranges to extract (ex: 2 or 5-23 or 2,5-7,12-)"));
}

From source file:intelligent.wiki.editor.gui.fx.dialogs.ModifyLinkDialog.java

private void initContent() {
    content.add(new Label(i18n.getString("insert-link-dialog.url-label-text")), 0, 0);
    content.add(urlInput, 1, 0);/*  w  w  w . j ava 2s . c  o m*/
    GridPane.setHgrow(urlInput, Priority.ALWAYS);

    content.add(new Label(i18n.getString("insert-link-dialog.caption-label-text")), 0, 1);
    content.add(captionInput, 1, 1);
    GridPane.setHgrow(captionInput, Priority.ALWAYS);
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Table View Sample");
    stage.setWidth(300);//from w  w w.  j av a2 s  .co m
    stage.setHeight(500);

    final Label label = new Label("Student IDs");
    label.setFont(new Font("Arial", 20));

    TableColumn<Map, String> firstDataColumn = new TableColumn<>("Class A");
    TableColumn<Map, String> secondDataColumn = new TableColumn<>("Class B");

    firstDataColumn.setCellValueFactory(new MapValueFactory(Column1MapKey));
    firstDataColumn.setMinWidth(130);
    secondDataColumn.setCellValueFactory(new MapValueFactory(Column2MapKey));
    secondDataColumn.setMinWidth(130);

    TableView tableView = new TableView<>(generateDataInMap());

    tableView.setEditable(true);
    tableView.getSelectionModel().setCellSelectionEnabled(true);
    tableView.getColumns().setAll(firstDataColumn, secondDataColumn);
    Callback<TableColumn<Map, String>, TableCell<Map, String>> cellFactoryForMap = (
            TableColumn<Map, String> p) -> new TextFieldTableCell(new StringConverter() {
                @Override
                public String toString(Object t) {
                    return t.toString();
                }

                @Override
                public Object fromString(String string) {
                    return string;
                }
            });
    firstDataColumn.setCellFactory(cellFactoryForMap);
    secondDataColumn.setCellFactory(cellFactoryForMap);

    final VBox vbox = new VBox();

    vbox.setSpacing(5);
    vbox.setPadding(new Insets(10, 0, 0, 10));
    vbox.getChildren().addAll(label, tableView);

    ((Group) scene.getRoot()).getChildren().addAll(vbox);

    stage.setScene(scene);

    stage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("JavaFX Welcome");
    GridPane grid = new GridPane();
    grid.setAlignment(Pos.CENTER);//from  w w w.j  a  va 2 s . com
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(25, 25, 25, 25));

    Text scenetitle = new Text("Welcome");
    scenetitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));
    grid.add(scenetitle, 0, 0, 2, 1);

    Label userName = new Label("User Name:");
    grid.add(userName, 0, 1);

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

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

    PasswordField pwBox = new PasswordField();
    grid.add(pwBox, 1, 2);

    Button btn = new Button("Sign in");
    HBox hbBtn = new HBox(10);
    hbBtn.setAlignment(Pos.BOTTOM_RIGHT);
    hbBtn.getChildren().add(btn);
    grid.add(hbBtn, 1, 4);

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

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

        @Override
        public void handle(ActionEvent e) {
            actiontarget.setFill(Color.FIREBRICK);
            actiontarget.setText("Sign in button pressed");
        }
    });

    Scene scene = new Scene(grid, 300, 275);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:com.canoo.dolphin.todo.client.ToDoClient.java

private void showError(String header, String content, Exception e) {
    e.printStackTrace();/* www .j  a v  a  2s  .  c  o  m*/

    Alert alert = new Alert(Alert.AlertType.ERROR);
    alert.setTitle("Error");
    alert.setHeaderText(header);
    alert.setContentText(content);

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    e.printStackTrace(pw);
    String exceptionText = sw.toString();

    Label label = new Label("The exception stacktrace was:");

    TextArea textArea = new TextArea(exceptionText);
    textArea.setEditable(false);
    textArea.setWrapText(true);

    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(textArea, Priority.ALWAYS);
    GridPane.setHgrow(textArea, Priority.ALWAYS);

    GridPane expContent = new GridPane();
    expContent.setMaxWidth(Double.MAX_VALUE);
    expContent.add(label, 0, 0);
    expContent.add(textArea, 0, 1);

    alert.getDialogPane().setExpandableContent(expContent);
    alert.showAndWait();
    System.exit(-1);
}

From source file:eu.over9000.skadi.ui.dialogs.PerformUpdateDialog.java

public PerformUpdateDialog(RemoteVersionResult newVersion) {
    this.chosen = new SimpleObjectProperty<>(
            Paths.get(SystemUtils.USER_HOME, newVersion.getVersion() + ".jar").toFile());

    this.setHeaderText("Updating to " + newVersion.getVersion());
    this.setTitle("Skadi Updater");
    this.getDialogPane().getStyleClass().add("alert");
    this.getDialogPane().getStyleClass().add("information");

    final ButtonType restartButtonType = new ButtonType("Start New Version", ButtonBar.ButtonData.OK_DONE);
    this.getDialogPane().getButtonTypes().addAll(restartButtonType, ButtonType.CANCEL);

    Node btn = this.getDialogPane().lookupButton(restartButtonType);
    btn.setDisable(true);// w w w.  j av a 2  s  . co  m

    Label lbPath = new Label("Save as");
    TextField tfPath = new TextField();
    tfPath.textProperty()
            .bind(Bindings.createStringBinding(() -> this.chosen.get().getAbsolutePath(), this.chosen));
    tfPath.setPrefColumnCount(40);
    tfPath.setEditable(false);

    Button btChangePath = GlyphsDude.createIconButton(FontAwesomeIcons.FOLDER_OPEN, "Browse...");
    btChangePath.setOnAction(event -> {
        FileChooser fc = new FileChooser();
        fc.setTitle("Save downloaded jar..");
        fc.setInitialFileName(this.chosen.getValue().getName());
        fc.getExtensionFilters().add(new FileChooser.ExtensionFilter("Jar File", ".jar"));
        fc.setInitialDirectory(this.chosen.getValue().getParentFile());
        File selected = fc.showSaveDialog(this.getOwner());
        if (selected != null) {
            this.chosen.set(selected);
        }
    });

    ProgressBar pbDownload = new ProgressBar(0);
    pbDownload.setDisable(true);
    pbDownload.setMaxWidth(Double.MAX_VALUE);
    Label lbDownload = new Label("Download");
    Label lbDownloadValue = new Label();
    Button btDownload = GlyphsDude.createIconButton(FontAwesomeIcons.DOWNLOAD, "Start");
    btDownload.setMaxWidth(Double.MAX_VALUE);
    btDownload.setOnAction(event -> {
        btChangePath.setDisable(true);
        btDownload.setDisable(true);

        this.downloadService = new DownloadService(newVersion.getDownloadURL(), this.chosen.getValue());

        lbDownloadValue.textProperty().bind(this.downloadService.messageProperty());
        pbDownload.progressProperty().bind(this.downloadService.progressProperty());

        this.downloadService.setOnSucceeded(dlEvent -> {
            btn.setDisable(false);
        });
        this.downloadService.setOnFailed(dlFailed -> {
            LOGGER.error("new version download failed", dlFailed.getSource().getException());
            lbDownloadValue.textProperty().unbind();
            lbDownloadValue.setText("Download failed, check log file for details.");
        });

        this.downloadService.start();
    });

    final GridPane grid = new GridPane();
    grid.setHgap(10);
    grid.setVgap(10);

    grid.add(lbPath, 0, 0);
    grid.add(tfPath, 1, 0);
    grid.add(btChangePath, 2, 0);
    grid.add(new Separator(), 0, 1, 3, 1);
    grid.add(lbDownload, 0, 2);
    grid.add(pbDownload, 1, 2);
    grid.add(btDownload, 2, 2);
    grid.add(lbDownloadValue, 1, 3);

    this.getDialogPane().setContent(grid);

    this.setResultConverter(btnType -> {
        if (btnType == restartButtonType) {
            return this.chosen.getValue();
        }

        if (btnType == ButtonType.CANCEL) {
            if (this.downloadService.isRunning()) {
                this.downloadService.cancel();
            }
        }

        return null;
    });

}

From source file:com.bdb.weather.display.current.Thermometer.java

/**
 * Constructor./*from ww  w . j  a va  2 s.co  m*/
 * 
 * @param title The title to display in the containing panel
 * @param min The minimum value for the thermometer scale
 * @param max The maximum value for the thermometer scale
 */
public Thermometer(String title, Temperature min, Temperature max) {
    this.setPrefSize(150.0, 200.0);
    minValue = min;
    maxValue = max;
    unitProperty.setValue(Temperature.getDefaultUnit());
    setUnits(unitProperty.getValue());
    ChartViewer chartViewer = createChartElements();
    this.setCenter(chartViewer);
    HBox p = new HBox();
    p.setAlignment(Pos.CENTER);
    Label label = new Label("High: ");
    label.setStyle("-fx-font-weight: bold");
    p.getChildren().addAll(label, highLabel);
    this.setTop(p);
    p = new HBox();
    p.setAlignment(Pos.CENTER);
    label = new Label("Low: ");
    label.setStyle("-fx-font-weight: bold");
    p.getChildren().addAll(label, lowLabel);
    this.setBottom(p);

    unitProperty.addListener((ObservableValue<? extends Temperature.Unit> observable, Temperature.Unit oldValue,
            Temperature.Unit newValue) -> {
        setUnits(newValue);
    });
}

From source file:com.bdb.weather.display.windrose.WindRosePane.java

/**
 * Constructor.//from  w  w w  .  j a v a 2 s. c  o m
 */
public WindRosePane() {
    this.setPrefSize(300, 300);
    ChartFactory.getChartTheme().apply(chart);
    chartViewer.setMinHeight(10);
    chartViewer.setMinWidth(10);
    chartViewer.setPrefSize(300, 300);

    dataTable = new TableView();

    FlowPane summaryPanel = new FlowPane();

    summaryPanel.getChildren().add(new LabeledFieldPane<>("Date:", timeField));
    timeField.setEditable(false);
    summaryPanel.getChildren().add(new LabeledFieldPane<>("% Winds are calm:", calmField));
    calmField.setEditable(false);

    summaryPanel.getChildren().add(new Label("Speeds are in " + Speed.getDefaultUnit()));

    BorderPane p = new BorderPane();

    p.setCenter(dataTable);
    p.setTop(summaryPanel);
    this.setTabContents(chartViewer, p);

    TableColumn<WindSlice, String> headingColumn = new TableColumn<>("Heading");
    headingColumn.setCellValueFactory((rec) -> new ReadOnlyStringWrapper(
            Heading.headingForSlice(rec.getValue().getHeadingIndex(), 16).getCompassLabel()));
    dataTable.getColumns().add(headingColumn);

    TableColumn<WindSlice, String> percentOfWindColumn = new TableColumn<>("% of Wind");
    percentOfWindColumn.setCellValueFactory(
            (rec) -> new ReadOnlyStringWrapper(String.format("%.1f", rec.getValue().getPercentageOfWind())));
    dataTable.getColumns().add(percentOfWindColumn);

    TableColumn<WindSlice, Speed> avgSpeedColumn = new TableColumn<>("Avg Speed");
    avgSpeedColumn.setCellValueFactory((rec) -> new ReadOnlyObjectWrapper<>(rec.getValue().getAvgSpeed()));
    dataTable.getColumns().add(avgSpeedColumn);

    TableColumn<WindSlice, Speed> maxSpeedColumn = new TableColumn<>("Max Speed");
    maxSpeedColumn.setCellValueFactory((rec) -> new ReadOnlyObjectWrapper<>(rec.getValue().getMaxSpeed()));
    dataTable.getColumns().add(maxSpeedColumn);

}