List of usage examples for javafx.scene.layout GridPane setPadding
public final void setPadding(Insets value)
From source file:de.perdian.apps.tagtiger.fx.handlers.batchupdate.UpdateFileNamesFromTagsActionEventHandler.java
private Parent createLegendPane() { GridPane legendPane = new GridPane(); legendPane.setPadding(new Insets(5, 5, 5, 5)); int columnCount = 3; int currentRow = 0; int currentColumn = 0; for (UpdateFileNamesPlaceholder placeholder : UpdateFileNamesPlaceholder.values()) { StringBuilder placeholderText = new StringBuilder(); placeholderText.append("${").append(placeholder.getPlaceholder()).append("}: "); placeholderText.append(placeholder.resolveLocalization(this.getLocalization())); Label placeholderLabel = new Label(placeholderText.toString()); placeholderLabel.setMaxWidth(Double.MAX_VALUE); placeholderLabel.setPadding(new Insets(3, 3, 3, 3)); placeholderLabel.setAlignment(Pos.TOP_LEFT); legendPane.add(placeholderLabel, currentColumn, currentRow); GridPane.setFillWidth(placeholderLabel, Boolean.TRUE); GridPane.setHgrow(placeholderLabel, Priority.ALWAYS); currentColumn++;//from w w w . ja v a 2 s . c om if (currentColumn >= columnCount) { currentRow++; currentColumn = 0; } } TitledPane legendTitlePane = new TitledPane(this.getLocalization().legend(), legendPane); legendTitlePane.setCollapsible(false); return legendTitlePane; }
From source file:de.perdoctus.ebikeconnect.gui.dialogs.LoginDialog.java
@PostConstruct public void init() { final ImageView graphic = new ImageView( new Image(getClass().getResource("/app-icon.png").toExternalForm())); graphic.setPreserveRatio(true);//from w w w . ja va 2 s . co m graphic.setFitHeight(64); setGraphic(graphic); setResizable(true); setWidth(400); setResizable(false); setTitle(rb.getString("dialogTitle")); setHeaderText(rb.getString("dialogMessage")); final ButtonType loginButtonType = new ButtonType(rb.getString("loginButton"), ButtonBar.ButtonData.OK_DONE); getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL); // Create the username and password labels and fields. final GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 10, 10, 10)); grid.setPrefWidth(getWidth()); grid.getColumnConstraints().add(new ColumnConstraints(-1, -1, -1, Priority.NEVER, HPos.LEFT, true)); grid.getColumnConstraints().add(new ColumnConstraints(-1, -1, -1, Priority.ALWAYS, HPos.LEFT, true)); final String rbUsername = rb.getString(CFG_USERNAME); final TextField txtUsername = new TextField(); txtUsername.setPromptText(rbUsername); txtUsername.setText(config.getString(CFG_USERNAME, "")); final Label lblUsername = new Label(rbUsername); lblUsername.setLabelFor(txtUsername); grid.add(lblUsername, 0, 0); grid.add(txtUsername, 1, 0); final String rbPassword = rb.getString(CFG_PASSWORD); final PasswordField txtPassword = new PasswordField(); txtPassword.setPromptText(rbPassword); if (config.getBoolean(CFG_SAVE_PASSWORD, false)) { txtPassword.setText(config.getString(CFG_PASSWORD, "")); } final Label lblPassword = new Label(rbPassword); lblPassword.setLabelFor(txtPassword); grid.add(lblPassword, 0, 1); grid.add(txtPassword, 1, 1); final CheckBox cbSavePassword = new CheckBox(rb.getString("save-password")); cbSavePassword.setSelected(config.getBoolean(CFG_SAVE_PASSWORD, false)); grid.add(cbSavePassword, 1, 2); getDialogPane().setContent(grid); // Enable/Disable login button depending on whether a username was entered. final Node loginButton = getDialogPane().lookupButton(loginButtonType); loginButton.disableProperty() .bind(txtUsername.textProperty().isEmpty().or(txtPassword.textProperty().isEmpty())); setResultConverter(buttonType -> { if (buttonType == loginButtonType) { config.setProperty(CFG_USERNAME, txtUsername.getText()); config.setProperty(CFG_SAVE_PASSWORD, cbSavePassword.isSelected()); if (cbSavePassword.isSelected()) { config.setProperty(CFG_PASSWORD, txtPassword.getText()); config.setProperty(CFG_PASSWORD, txtPassword.getText()); } else { config.clearProperty(CFG_PASSWORD); } return new Credentials(txtUsername.getText(), txtPassword.getText()); } else { return null; } }); if (txtUsername.getText().isEmpty()) { txtUsername.requestFocus(); } else { txtPassword.requestFocus(); txtPassword.selectAll(); } }
From source file:Main.java
private GridPane addGridPane() { GridPane grid = new GridPane(); grid.setHgap(10);// w ww . jav a 2 s .com 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:fruitproject.FruitProject.java
public void third(final String pfname) { final Stage st = new Stage(); GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER);//from w ww . j av a 2 s. c om grid.setHgap(10); 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:org.beryx.viewreka.fxapp.ProjectLibs.java
public void installLibs(String prjName, File prjDir) { InstallLibsTask task = new InstallLibsTask(prjName, prjDir, lstLib); Stage progressStage = new Stage(); progressStage.setOnCloseRequest(ev -> { if (Dialogs.confirmYesNo("Cancel", "Are you sure you want to cancel the installation of project libraries?", null)) { task.cancel();// w w w . java2 s . com } }); progressStage.initStyle(StageStyle.UTILITY); progressStage.initModality(Modality.APPLICATION_MODAL); progressStage.setTitle("Create project " + prjName); GridPane grid = new GridPane(); grid.setHgap(20); grid.setVgap(20); grid.setPadding(new Insets(24, 10, 0, 24)); ProgressIndicator progressIndicator = new ProgressIndicator(); progressIndicator.setPrefSize(64, 64); progressIndicator.setMinSize(64, 64); progressIndicator.setMaxSize(64, 64); // progressIndicator.progressProperty().bind(task.progressProperty()); grid.add(progressIndicator, 0, 0); Label actionLabel = new Label("Install project libraries..."); actionLabel.textProperty().bind(task.messageProperty()); grid.add(actionLabel, 1, 0); progressStage.setScene(new Scene(grid, 600, 120)); task.setOnSucceeded(ev -> closeProgress(progressStage, task)); task.setOnFailed(ev -> closeProgress(progressStage, task)); task.setOnCancelled(ev -> closeProgress(progressStage, task)); progressStage.setOnShown(ev -> Executors.newSingleThreadExecutor().submit(task)); progressStage.showAndWait(); }
From source file:fruitproject.FruitProject.java
public void first(final Stage primaryStage) { GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER);/*from w w w . j a v a2s .co m*/ grid.setHgap(10); 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:com.danilafe.sbaccountmanager.StarboundServerAccountManager.java
private void createBannedUser(ListView<String> to_update) { Stage createBannedUser = new Stage(); createBannedUser.setTitle("Add Banned User"); createBannedUser.initModality(Modality.APPLICATION_MODAL); GridPane gp = new GridPane(); gp.setPadding(new Insets(25, 25, 25, 25)); gp.setAlignment(Pos.CENTER);/*w w w .j ava 2s. c o m*/ gp.setVgap(10); gp.setHgap(10); Text title = new Text("Add Banned Username"); title.setFont(Font.font("Century Gothic", FontWeight.NORMAL, 20)); gp.add(title, 0, 0, 2, 1); Label newusername = new Label("Ban Username"); TextField username = new TextField(); gp.add(newusername, 0, 1); gp.add(username, 1, 1); Button finish = new Button("Finish"); HBox finish_box = new HBox(10); finish_box.setAlignment(Pos.CENTER); finish_box.getChildren().add(finish); finish.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { banned_usernames.remove(username.getText()); banned_usernames.add(username.getText()); to_update.setItems(FXCollections.observableArrayList(banned_usernames)); createBannedUser.close(); } }); gp.add(finish_box, 0, 2, 2, 1); Scene sc = new Scene(gp, 300, 175); createBannedUser.setScene(sc); createBannedUser.show(); }
From source file:com.danilafe.sbaccountmanager.StarboundServerAccountManager.java
private void createBannedIP(ListView<String> to_update) { Stage createBannedIP = new Stage(); createBannedIP.setTitle("Add Banned IP"); createBannedIP.initModality(Modality.APPLICATION_MODAL); GridPane gp = new GridPane(); gp.setPadding(new Insets(25, 25, 25, 25)); gp.setAlignment(Pos.CENTER);//w ww .ja v a 2 s. c o m gp.setVgap(10); gp.setHgap(10); Text title = new Text("Add Banned IP"); title.setFont(Font.font("Century Gothic", FontWeight.NORMAL, 20)); gp.add(title, 0, 0, 2, 1); Label newusername = new Label("Ban IP"); TextField username = new TextField(); gp.add(newusername, 0, 1); gp.add(username, 1, 1); Button finish = new Button("Finish"); HBox finish_box = new HBox(10); finish_box.setAlignment(Pos.CENTER); finish_box.getChildren().add(finish); finish.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { banned_ips.remove(username.getText()); banned_ips.add(username.getText()); to_update.setItems(FXCollections.observableArrayList(banned_ips)); createBannedIP.close(); } }); gp.add(finish_box, 0, 2, 2, 1); Scene sc = new Scene(gp, 300, 175); createBannedIP.setScene(sc); createBannedIP.show(); }
From source file:com.danilafe.sbaccountmanager.StarboundServerAccountManager.java
private void createBannedPlayername(ListView<String> to_update) { Stage createBannedPlayername = new Stage(); createBannedPlayername.setTitle("Add Banned Playername"); createBannedPlayername.initModality(Modality.APPLICATION_MODAL); GridPane gp = new GridPane(); gp.setPadding(new Insets(25, 25, 25, 25)); gp.setAlignment(Pos.CENTER);/*from ww w . ja v a 2s . c o m*/ gp.setVgap(10); gp.setHgap(10); Text title = new Text("Add Banned Playername"); title.setFont(Font.font("Century Gothic", FontWeight.NORMAL, 20)); gp.add(title, 0, 0, 2, 1); Label newusername = new Label("Ban Playername"); TextField username = new TextField(); gp.add(newusername, 0, 1); gp.add(username, 1, 1); Button finish = new Button("Finish"); HBox finish_box = new HBox(10); finish_box.setAlignment(Pos.CENTER); finish_box.getChildren().add(finish); finish.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { banned_playernames.remove(username.getText()); banned_playernames.add(username.getText()); to_update.setItems(FXCollections.observableArrayList(banned_playernames)); createBannedPlayername.close(); } }); gp.add(finish_box, 0, 2, 2, 1); Scene sc = new Scene(gp, 300, 175); createBannedPlayername.setScene(sc); createBannedPlayername.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);//from w w w. j a v a 2s . c o m gp.setHgap(10d); 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 }