List of usage examples for javafx.scene.control Button Button
public Button(String text)
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle("Background Processes"); Group root = new Group(); Scene scene = new Scene(root, 330, 120, Color.WHITE); BorderPane mainPane = new BorderPane(); root.getChildren().add(mainPane);// w w w. j a v a2 s. c o m final Label label = new Label("Files Transfer:"); final ProgressBar progressBar = new ProgressBar(0); final HBox hb = new HBox(); hb.setSpacing(5); hb.setAlignment(Pos.CENTER); hb.getChildren().addAll(label, progressBar); mainPane.setTop(hb); final Button startButton = new Button("Start"); final Button cancelButton = new Button("Cancel"); final HBox hb2 = new HBox(); hb2.setSpacing(5); hb2.setAlignment(Pos.CENTER); hb2.getChildren().addAll(startButton, cancelButton); mainPane.setBottom(hb2); startButton.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { startButton.setDisable(true); progressBar.setProgress(0); cancelButton.setDisable(false); copyWorker = createWorker(); progressBar.progressProperty().unbind(); progressBar.progressProperty().bind(copyWorker.progressProperty()); copyWorker.messageProperty().addListener(new ChangeListener<String>() { public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { System.out.println(newValue); } }); new Thread(copyWorker).start(); } }); cancelButton.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { startButton.setDisable(false); cancelButton.setDisable(true); copyWorker.cancel(true); progressBar.progressProperty().unbind(); progressBar.setProgress(0); System.out.println("cancelled."); } }); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle("Background Processes"); Group root = new Group(); Scene scene = new Scene(root, 330, 120, Color.WHITE); BorderPane mainPane = new BorderPane(); root.getChildren().add(mainPane);/*w w w. ja v a2 s .c om*/ final Label label = new Label("Files Transfer:"); final ProgressIndicator progressIndicator = new ProgressIndicator(0); final HBox hb = new HBox(); hb.setSpacing(5); hb.setAlignment(Pos.CENTER); hb.getChildren().addAll(label, progressIndicator); mainPane.setTop(hb); final Button startButton = new Button("Start"); final Button cancelButton = new Button("Cancel"); final HBox hb2 = new HBox(); hb2.setSpacing(5); hb2.setAlignment(Pos.CENTER); hb2.getChildren().addAll(startButton, cancelButton); mainPane.setBottom(hb2); startButton.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { startButton.setDisable(true); progressIndicator.setProgress(0); cancelButton.setDisable(false); copyWorker = createWorker(); progressIndicator.progressProperty().unbind(); progressIndicator.progressProperty().bind(copyWorker.progressProperty()); copyWorker.messageProperty().addListener(new ChangeListener<String>() { public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { System.out.println(newValue); } }); new Thread(copyWorker).start(); } }); cancelButton.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { startButton.setDisable(false); cancelButton.setDisable(true); copyWorker.cancel(true); progressIndicator.progressProperty().unbind(); progressIndicator.setProgress(0); System.out.println("cancelled."); } }); primaryStage.setScene(scene); primaryStage.show(); }
From source file:ijfx.ui.filter.FilterTest.java
@Override public void start(Stage primaryStage) throws Exception { borderPane = new BorderPane(); borderPane.getStylesheets().add(ImageJFX.getStylesheet()); borderPane.getStyleClass().add("explorer-filter"); Button updateButton = new Button("Update values"); filter = new DefaultNumberFilter(); Scene scene = new Scene(borderPane); primaryStage.setScene(scene);//from w w w . j a v a 2 s . c o m borderPane.setCenter(filter.getContent()); borderPane.setBottom(updateButton); updateButton.setOnAction(this::update); primaryStage.show(); }
From source file:eu.ggnet.dwoss.util.OkCancelStage.java
public OkCancelStage(String title, T payload) { this.payload = payload; BorderPane pane = new BorderPane(); pane.setCenter(payload);/*from w w w. ja va 2 s . c o m*/ Button okButton = new Button("Ok"); okButton.defaultButtonProperty(); Button cancelButton = new Button("Abbrechen"); cancelButton.setCancelButton(true); HBox bottom = new HBox(); bottom.setPadding(new Insets(10)); bottom.getChildren().addAll(okButton, cancelButton); pane.setBottom(bottom); if (!StringUtils.isBlank(title)) setTitle(title); setScene(new Scene(pane)); okButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { OkCancelStage.this.ok = true; close(); } }); cancelButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { close(); } }); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setWidth(450);//from w w w . java 2 s. c o m stage.setHeight(550); TableColumn firstNameCol = new TableColumn("First Name"); firstNameCol.setMinWidth(100); firstNameCol.setCellValueFactory(new PropertyValueFactory<>("firstName")); TableColumn lastNameCol = new TableColumn("Last Name"); lastNameCol.setMinWidth(100); lastNameCol.setCellValueFactory(new PropertyValueFactory<>("lastName")); table.setItems(data); table.getColumns().addAll(firstNameCol, lastNameCol); final Button addButton = new Button("Add"); addButton.setOnAction((ActionEvent e) -> { data.add(new Person("Z", "X")); }); hb.getChildren().addAll(addButton); hb.setSpacing(3); final VBox vbox = new VBox(); vbox.setSpacing(5); vbox.setPadding(new Insets(10, 0, 0, 10)); vbox.getChildren().addAll(table, hb); ((Group) scene.getRoot()).getChildren().addAll(vbox); stage.setScene(scene); stage.show(); }
From source file:tachyon.view.Viewer.java
public Viewer(Resource scr, Project pro) { super(scr, pro); getCenter().setCenter(new ScrollPane(view = new ImageView(image = readFromFile(scr.getFile())))); controls = new ToolBar(); controls.setPadding(new Insets(5, 10, 5, 10)); getCenter().setTop(controls);/* ww w.j a v a 2s . com*/ controls.getItems().addAll(zIn = new Button("Zoom In"), zOut = new Button("Zoom Out"), new Separator(), rotate = new Button("Rotate"), new Separator(), revert = new Button("Revert")); zIn.setOnAction((e) -> { if (zoom.get() < 2.0) { zoom.set(zoom.get() + 0.1); } }); zOut.setOnAction((e) -> { if (zoom.get() > 0.2) { zoom.set(zoom.get() - 0.1); } }); zoom.addListener((ob, older, newer) -> { view.setFitHeight(newer.doubleValue() * image.getHeight()); view.setFitWidth(newer.doubleValue() * image.getWidth()); }); rotate.setOnAction((e) -> { view.setRotate(view.getRotate() + 90); }); revert.setOnAction((e) -> { zoom.set(1.0); view.setRotate(0); }); }
From source file:org.pdfsam.ui.commons.ClosePaneTest.java
@Override protected Parent getRootNode() { victimStage = new Stage(); ClosePane containerPane = new ClosePane(); Scene scene = new Scene(containerPane); victimStage.setScene(scene);/* w ww .java 2 s . c o m*/ Button button = new Button("show"); button.setOnAction(a -> victimStage.show()); return button; }
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 av a 2s.c o m 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
public MyDialog(Stage owner) { super();//from ww w . j a v a 2s . co m 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.TestManager.java
/** * Displays given test. Intended for testing and * evaluating correct answers. (student mode only) * @param test test to display/*from ww w . ja v a 2 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(); }