List of usage examples for javafx.scene.control Label Label
public Label(String text)
From source file:Main.java
@Override public void start(Stage stage) { final Stage stageRef = stage; Group rootGroup;/*from w w w. j a va 2 s.c o m*/ TextField titleTextField; Scene scene = SceneBuilder .create().width(270).height(370).root( rootGroup = GroupBuilder.create() .children(HBoxBuilder.create().spacing(10) .children(new Label("title:"), titleTextField = TextFieldBuilder.create() .text("Stage Coach").prefColumnCount(15).build()) .build()) .build()) .build(); title.bind(titleTextField.textProperty()); stage.setScene(scene); stage.titleProperty().bind(title); stage.show(); }
From source file:Main.java
public MyDialog(Stage owner) { super();/*from w ww .j a v a 2 s.c om*/ initOwner(owner); setTitle("title"); Group root = new Group(); Scene scene = new Scene(root, 250, 150, Color.WHITE); setScene(scene); GridPane gridpane = new GridPane(); gridpane.setPadding(new Insets(5)); gridpane.setHgap(5); gridpane.setVgap(5); Label userNameLbl = new Label("User Name: "); gridpane.add(userNameLbl, 0, 1); Label passwordLbl = new Label("Password: "); gridpane.add(passwordLbl, 0, 2); final TextField userNameFld = new TextField("Admin"); gridpane.add(userNameFld, 1, 1); final PasswordField passwordFld = new PasswordField(); passwordFld.setText("password"); gridpane.add(passwordFld, 1, 2); Button login = new Button("Change"); login.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { close(); } }); gridpane.add(login, 1, 3); GridPane.setHalignment(login, HPos.RIGHT); root.getChildren().add(gridpane); }
From source file:Main.java
@Override public void start(Stage primaryStage) { BorderPane root = new BorderPane(); Scene scene = new Scene(root, 400, 250, Color.WHITE); GridPane gridpane = new GridPane(); gridpane.setPadding(new Insets(5)); gridpane.setHgap(10);/*www.j a v a2 s . c om*/ gridpane.setVgap(10); ColumnConstraints column1 = new ColumnConstraints(150, 150, Double.MAX_VALUE); ColumnConstraints column2 = new ColumnConstraints(50); ColumnConstraints column3 = new ColumnConstraints(150, 150, Double.MAX_VALUE); column1.setHgrow(Priority.ALWAYS); column3.setHgrow(Priority.ALWAYS); gridpane.getColumnConstraints().addAll(column1, column2, column3); Label candidatesLbl = new Label("Candidates"); GridPane.setHalignment(candidatesLbl, HPos.CENTER); gridpane.add(candidatesLbl, 0, 0); Label selectedLbl = new Label("selected"); gridpane.add(selectedLbl, 2, 0); GridPane.setHalignment(selectedLbl, HPos.CENTER); // Candidates final ObservableList<String> candidates = FXCollections.observableArrayList("Z", "A", "B", "C", "D"); final ListView<String> candidatesListView = new ListView<>(candidates); gridpane.add(candidatesListView, 0, 1); final ObservableList<String> selected = FXCollections.observableArrayList(); final ListView<String> heroListView = new ListView<>(selected); gridpane.add(heroListView, 2, 1); Button sendRightButton = new Button(" > "); sendRightButton.setOnAction((ActionEvent event) -> { String potential = candidatesListView.getSelectionModel().getSelectedItem(); if (potential != null) { candidatesListView.getSelectionModel().clearSelection(); candidates.remove(potential); selected.add(potential); } }); Button sendLeftButton = new Button(" < "); sendLeftButton.setOnAction((ActionEvent event) -> { String s = heroListView.getSelectionModel().getSelectedItem(); if (s != null) { heroListView.getSelectionModel().clearSelection(); selected.remove(s); candidates.add(s); } }); VBox vbox = new VBox(5); vbox.getChildren().addAll(sendRightButton, sendLeftButton); gridpane.add(vbox, 1, 1); root.setCenter(gridpane); GridPane.setVgrow(root, Priority.ALWAYS); primaryStage.setScene(scene); primaryStage.show(); }
From source file:main.TestManager.java
/** * Displays given test. Intended for testing and * evaluating correct answers. (student mode only) * @param test test to display/* w ww . j av a2 s. c o m*/ * @param stage */ public static void displayTest(Test test, Stage stage) { Debugger.println(test.getName() + " - is displayed."); TabPane tabPane = new TabPane(); int counter = 1; for (Question q : test.getQuestions()) { Label instruction = new Label(q.question); instruction.setStyle("-fx-font-size: 20"); Pane choices = q.getPaneOfChoices(); VBox vbox = new VBox(instruction, choices); vbox.setSpacing(10); Tab tab = new Tab("Otzka " + Integer.toString(counter), vbox); tab.setStyle("-fx-font-size: 20"); tabPane.getTabs().add(tab); counter++; } Button finish = new Button("Ukon?i test!"); finish.setStyle("-fx-font-size: 20"); finish.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { try { test.evaluate(stage); } catch (IOException e) { Alert alert = new Alert(AlertType.ERROR); alert.setContentText("Ojoj, vyskytol sa problm. Aplikcia sa mus ukon?i."); alert.showAndWait(); System.exit(0); } } }); Button nextQuestion = new Button("alia"); nextQuestion.setStyle("-fx-font-size: 20"); nextQuestion.setOnAction(e -> tabPane.getSelectionModel().selectNext()); HBox buttons = new HBox(finish, nextQuestion); buttons.setSpacing(10); buttons.setAlignment(Pos.BOTTOM_CENTER); VBox outerVBox = new VBox(tabPane, buttons); outerVBox.setPadding(new Insets(10, 10, 10, 10)); Scene scene = new Scene(outerVBox); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { BorderPane root = new BorderPane(); Scene scene = new Scene(root, 400, 250, Color.WHITE); GridPane gridpane = new GridPane(); gridpane.setPadding(new Insets(5)); gridpane.setHgap(10);/*from w w w . j av a 2 s .co m*/ gridpane.setVgap(10); ColumnConstraints column1 = new ColumnConstraints(150, 150, Double.MAX_VALUE); ColumnConstraints column2 = new ColumnConstraints(50); ColumnConstraints column3 = new ColumnConstraints(150, 150, Double.MAX_VALUE); column1.setHgrow(Priority.ALWAYS); column3.setHgrow(Priority.ALWAYS); gridpane.getColumnConstraints().addAll(column1, column2, column3); // Candidates label Label candidatesLbl = new Label("Candidates"); GridPane.setHalignment(candidatesLbl, HPos.CENTER); gridpane.add(candidatesLbl, 0, 0); // Heroes label Label heroesLbl = new Label("Letters"); gridpane.add(heroesLbl, 2, 0); GridPane.setHalignment(heroesLbl, HPos.CENTER); final ObservableList<String> candidates = FXCollections.observableArrayList("A", "B", "C", "D"); final ListView<String> candidatesListView = new ListView<>(candidates); gridpane.add(candidatesListView, 0, 1); final ObservableList<String> heroes = FXCollections.observableArrayList(); final ListView<String> heroListView = new ListView<>(heroes); gridpane.add(heroListView, 2, 1); Button sendRightButton = new Button(" > "); sendRightButton.setOnAction((ActionEvent event) -> { String potential = candidatesListView.getSelectionModel().getSelectedItem(); if (potential != null) { candidatesListView.getSelectionModel().clearSelection(); candidates.remove(potential); heroes.add(potential); } }); Button sendLeftButton = new Button(" < "); sendLeftButton.setOnAction((ActionEvent event) -> { String notHero = heroListView.getSelectionModel().getSelectedItem(); if (notHero != null) { heroListView.getSelectionModel().clearSelection(); heroes.remove(notHero); candidates.add(notHero); } }); // place the buttons VBox vbox = new VBox(5); vbox.setAlignment(Pos.CENTER); vbox.getChildren().addAll(sendRightButton, sendLeftButton); GridPane.setHalignment(vbox, HPos.CENTER); gridpane.add(vbox, 1, 1); // place the grid root.setCenter(gridpane); GridPane.setVgrow(root, Priority.ALWAYS); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { final Label label = new Label("Progress:"); final ProgressBar progressBar = new ProgressBar(0); final ProgressIndicator progressIndicator = new ProgressIndicator(0); final Button startButton = new Button("Start"); final Button cancelButton = new Button("Cancel"); final TextArea textArea = new TextArea(); startButton.setOnAction((ActionEvent event) -> { startButton.setDisable(true);/* w w w . j a v a 2s. com*/ progressBar.setProgress(0); progressIndicator.setProgress(0); textArea.setText(""); cancelButton.setDisable(false); copyWorker = createWorker(numFiles); progressBar.progressProperty().unbind(); progressBar.progressProperty().bind(copyWorker.progressProperty()); progressIndicator.progressProperty().unbind(); progressIndicator.progressProperty().bind(copyWorker.progressProperty()); copyWorker.messageProperty().addListener( (ObservableValue<? extends String> observable, String oldValue, String newValue) -> { textArea.appendText(newValue + "\n"); }); new Thread(copyWorker).start(); }); cancelButton.setOnAction((ActionEvent event) -> { startButton.setDisable(false); cancelButton.setDisable(true); copyWorker.cancel(true); progressBar.progressProperty().unbind(); progressBar.setProgress(0); progressIndicator.progressProperty().unbind(); progressIndicator.setProgress(0); textArea.appendText("File transfer was cancelled."); }); BorderPane root = new BorderPane(); Scene scene = new Scene(root, 500, 250, javafx.scene.paint.Color.WHITE); FlowPane topPane = new FlowPane(5, 5); topPane.setPadding(new Insets(5)); topPane.setAlignment(Pos.CENTER); topPane.getChildren().addAll(label, progressBar, progressIndicator); GridPane middlePane = new GridPane(); middlePane.setPadding(new Insets(5)); middlePane.setHgap(20); middlePane.setVgap(20); ColumnConstraints column1 = new ColumnConstraints(300, 400, Double.MAX_VALUE); middlePane.getColumnConstraints().addAll(column1); middlePane.setAlignment(Pos.CENTER); middlePane.add(textArea, 0, 0); FlowPane bottomPane = new FlowPane(5, 5); bottomPane.setPadding(new Insets(5)); bottomPane.setAlignment(Pos.CENTER); bottomPane.getChildren().addAll(startButton, cancelButton); root.setTop(topPane); root.setCenter(middlePane); root.setBottom(bottomPane); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { VBox vbox = new VBox(20); Scene scene = new Scene(vbox, 400, 400); stage.setScene(scene);/* w w w .j a v a2s . c o m*/ DatePicker startDatePicker = new DatePicker(); DatePicker endDatePicker = new DatePicker(); startDatePicker.setValue(LocalDate.now()); final Callback<DatePicker, DateCell> dayCellFactory = new Callback<DatePicker, DateCell>() { @Override public DateCell call(final DatePicker datePicker) { return new DateCell() { @Override public void updateItem(LocalDate item, boolean empty) { super.updateItem(item, empty); if (item.isBefore(startDatePicker.getValue().plusDays(1))) { setDisable(true); setStyle("-fx-background-color: #EEEEEE;"); } } }; } }; endDatePicker.setDayCellFactory(dayCellFactory); endDatePicker.setValue(startDatePicker.getValue().plusDays(1)); vbox.getChildren().add(new Label("Start Date:")); vbox.getChildren().add(startDatePicker); vbox.getChildren().add(new Label("End Date:")); vbox.getChildren().add(endDatePicker); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { VBox vbox = new VBox(20); Scene scene = new Scene(vbox, 400, 400); stage.setScene(scene);/*from w w w . j a va 2 s .co m*/ final DatePicker startDatePicker = new DatePicker(); DatePicker endDatePicker = new DatePicker(); startDatePicker.setValue(LocalDate.now()); final Callback<DatePicker, DateCell> dayCellFactory = new Callback<DatePicker, DateCell>() { @Override public DateCell call(final DatePicker datePicker) { return new DateCell() { @Override public void updateItem(LocalDate item, boolean empty) { super.updateItem(item, empty); long p = ChronoUnit.DAYS.between(startDatePicker.getValue(), item); setTooltip(new Tooltip("You're about to stay for " + p + " days")); } }; } }; endDatePicker.setDayCellFactory(dayCellFactory); endDatePicker.setValue(startDatePicker.getValue().plusDays(1)); vbox.getChildren().add(new Label("Start Date:")); vbox.getChildren().add(startDatePicker); vbox.getChildren().add(new Label("End Date:")); vbox.getChildren().add(endDatePicker); stage.show(); }
From source file:kz.aksay.polygraph.desktop.LoginPane.java
public LoginPane() { GridPane grid = this; grid.setAlignment(Pos.CENTER);// w w w . j av a2s. c om grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); sceneTitle = new Text(" "); sceneTitle.setId("welcome-text"); grid.add(sceneTitle, 0, 0, 2, 1); userName = new Label(":"); grid.add(userName, 0, 1); userTextField = new TextField(); grid.add(userTextField, 1, 1); password = new Label(":"); grid.add(password, 0, 2); passwordTextBox = new PasswordField(); grid.add(passwordTextBox, 1, 2); signIn = new Button(""); HBox hbBtn = new HBox(10); hbBtn.setAlignment(Pos.BOTTOM_RIGHT); hbBtn.getChildren().add(signIn); grid.add(hbBtn, 1, 4); final Text actionTarget = new Text(); actionTarget.setId("action-target"); actionTarget.setWrappingWidth(300); grid.add(actionTarget, 0, 6, 2, 1); signIn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { if (isSignInSuccess()) { onSignInSuccess.handle(e); } else { actionTarget.setText( "? . !"); } } }); }
From source file:Main.java
@Override public void start(Stage stage) { TextField fName = new TextField(); TextField lName = new TextField(); TextField salary = new TextField(); Button closeBtn = new Button("Close"); closeBtn.setOnAction(e -> Platform.exit()); fName.getProperties().put("microHelpText", "Enter the first name"); lName.getProperties().put("microHelpText", "Enter the last name"); salary.getProperties().put("microHelpText", "Enter a salary greater than $2000.00."); // The help text node is unmanaged helpText.setManaged(false);/*www .ja va2 s . c o m*/ helpText.setTextOrigin(VPos.TOP); helpText.setFill(Color.RED); helpText.setFont(Font.font(null, 9)); helpText.setMouseTransparent(true); // Add all nodes to a GridPane GridPane root = new GridPane(); root.add(new Label("First Name:"), 1, 1); root.add(fName, 2, 1); root.add(new Label("Last Name:"), 1, 2); root.add(lName, 2, 2); root.add(new Label("Salary:"), 1, 3); root.add(salary, 2, 3); root.add(closeBtn, 3, 3); root.add(helpText, 4, 3); Scene scene = new Scene(root, 300, 100); // Add a change listener to the scene, so we know when // the focus owner changes and display the micro help scene.focusOwnerProperty().addListener((ObservableValue<? extends Node> value, Node oldNode, Node newNode) -> focusChanged(value, oldNode, newNode)); stage.setScene(scene); stage.setTitle("Showing Micro Help"); stage.show(); }