List of usage examples for javafx.scene.layout GridPane setAlignment
public final void setAlignment(Pos value)
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle("JavaFX Welcome"); GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER); grid.setHgap(10);//from ww w.j a v a 2s. c om 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:kz.aksay.polygraph.desktop.LoginPane.java
public LoginPane() { GridPane grid = this; grid.setAlignment(Pos.CENTER); grid.setHgap(10);/* www . j ava2 s.com*/ 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:org.jacp.demo.components.ContactChartViewComponent.java
private GridPane createRoot() { final GridPane myRoot = new GridPane(); myRoot.getStyleClass().addAll("dark", "bar-chart-root"); myRoot.setAlignment(Pos.CENTER); GridPane.setHgrow(myRoot, Priority.ALWAYS); GridPane.setVgrow(myRoot, Priority.ALWAYS); return myRoot; }
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);//from w ww. j a v a2 s . 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:fruitproject.FruitProject.java
public void third(final String pfname) { final Stage st = new Stage(); GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER); grid.setHgap(10);// w ww. j av a 2s . c o m grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); Label label1 = new Label("New Fruit"); grid.add(label1, 1, 0); final TextField txtName = new TextField(); grid.add(txtName, 1, 1); final TextField txtAmount = new TextField(); grid.add(txtAmount, 1, 2); Button btn = new Button(); btn.setText("OK"); grid.add(btn, 1, 3); btn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { //System.out.println("Hello World!"); addPairs.add(txtName.getText()); addPairs.add(txtAmount.getText()); st.close(); second(pfname); } }); Scene scene = new Scene(grid, 500, 500); st.setScene(scene); st.show(); }
From source file:fruitproject.FruitProject.java
public void first(final Stage primaryStage) { GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER); grid.setHgap(10);/*from w ww. j av a2 s . co m*/ 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:de.pixida.logtest.designer.logreader.LogReaderEditor.java
private void createDialogItems() { Validate.notNull(this.logReader); // Will be used to initialize input field values // CHECKSTYLE:OFF Yes, we are using lots of constants here. It does not make sense to name them using final variables. final GridPane gp = new GridPane(); gp.setAlignment(Pos.BASELINE_LEFT); gp.setHgap(10d);// ww w .j av a2s .c o m gp.setVgap(15d); gp.setPadding(new Insets(5d)); final ColumnConstraints column1 = new ColumnConstraints(); final ColumnConstraints column2 = new ColumnConstraints(); column1.setHgrow(Priority.NEVER); column2.setHgrow(Priority.SOMETIMES); gp.getColumnConstraints().addAll(column1, column2); this.insertConfigItemsIntoGrid(gp, this.createConfigurationForm()); final TitledPane configPane = new TitledPane("Edit Configuration", gp); configPane.setGraphic(Icons.getIconGraphics("pencil")); configPane.setCollapsible(false); final VBox lines = this.createRunForm(); final TitledPane testPane = new TitledPane("Test Configuration", lines); testPane.setGraphic(Icons.getIconGraphics("script_go")); testPane.setCollapsible(false); final VBox panes = new VBox(configPane, testPane); panes.setSpacing(10d); final ScrollPane sp = new ScrollPane(panes); sp.setPadding(new Insets(10d)); sp.setFitToWidth(true); this.setCenter(sp); // CHECKSTYLE:ON }
From source file:de.pixida.logtest.designer.testrun.TestRunEditor.java
public TitledPane createPanelForConfiguration() { final GridPane gp = new GridPane(); gp.setAlignment(Pos.BASELINE_LEFT); final double hGapOfGridPane = 10d; gp.setHgap(hGapOfGridPane);/* w w w . j av a 2s. co m*/ final double vGapOfGridPane = 15d; gp.setVgap(vGapOfGridPane); final double paddingOfGridPane = 5d; gp.setPadding(new Insets(paddingOfGridPane)); final ColumnConstraints column1 = new ColumnConstraints(); final ColumnConstraints column2 = new ColumnConstraints(); column1.setHgrow(Priority.NEVER); column2.setHgrow(Priority.SOMETIMES); gp.getColumnConstraints().addAll(column1, column2); this.insertConfigItemsIntoGrid(gp, this.createConfigurationForm()); final TitledPane configPane = new TitledPane("Edit Configuration", gp); configPane.setGraphic(Icons.getIconGraphics("pencil")); configPane.setCollapsible(false); return configPane; }
From source file:fruitproject.FruitProject.java
public void second(final String pfname) { final Stage st = new Stage(); Scene scene = null;// www .jav a 2s . c o 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: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); root.setHgap(10);//from w w w .ja v a 2 s . c o m 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(); }