List of usage examples for javafx.geometry Pos CENTER
Pos CENTER
To view the source code for javafx.geometry Pos CENTER.
Click Source Link
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle("Split Views"); Group root = new Group(); Scene scene = new Scene(root, 350, 250, Color.WHITE); SplitPane splitPane = new SplitPane(); splitPane.prefWidthProperty().bind(scene.widthProperty()); splitPane.prefHeightProperty().bind(scene.heightProperty()); VBox leftArea = new VBox(10); HBox rowBox = new HBox(20); final Text leftText = TextBuilder.create().text("Left ").translateX(20).fill(Color.RED) .font(Font.font(null, FontWeight.BOLD, 20)).build(); rowBox.getChildren().add(leftText);/*from ww w . j av a 2 s . c o m*/ leftArea.getChildren().add(rowBox); leftArea.setAlignment(Pos.CENTER); SplitPane splitPane2 = new SplitPane(); splitPane2.setOrientation(Orientation.VERTICAL); splitPane2.prefWidthProperty().bind(scene.widthProperty()); splitPane2.prefHeightProperty().bind(scene.heightProperty()); HBox centerArea = new HBox(); final Text upperRight = TextBuilder.create().text("Text").x(100).y(50).fill(Color.RED) .font(Font.font(null, FontWeight.BOLD, 35)).translateY(50).build(); centerArea.getChildren().add(upperRight); HBox rightArea = new HBox(); final Text lowerRight = TextBuilder.create().text("Lower Right").x(100).y(50).fill(Color.RED) .font(Font.font(null, FontWeight.BOLD, 35)).translateY(50).build(); rightArea.getChildren().add(lowerRight); splitPane2.getItems().add(centerArea); splitPane2.getItems().add(rightArea); splitPane.getItems().add(leftArea); splitPane.getItems().add(splitPane2); ObservableList<SplitPane.Divider> dividers = splitPane.getDividers(); for (int i = 0; i < dividers.size(); i++) { dividers.get(i).setPosition((i + 1.0) / 3); } HBox hbox = new HBox(); hbox.getChildren().add(splitPane); root.getChildren().add(hbox); 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);//w w w .j a va 2s.c o m 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) { Scene scene = new Scene(new Group()); scene.setFill(Color.ALICEBLUE); stage.setScene(scene);//from w w w .j a v a 2s .c o m stage.show(); stage.setWidth(300); stage.setHeight(200); label.setStyle("-fx-font: 25 arial;"); label.setLayoutX(40); rect.setStroke(Color.BLUE); rect.setStrokeWidth(3); rect.setFill(Color.WHITE); final String[] greetings = new String[] { "A", "B", "C", "D", "E" }; final ChoiceBox<String> cb = new ChoiceBox<String>( FXCollections.observableArrayList("a", "b", "c", "d", "e")); cb.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { public void changed(ObservableValue ov, Number value, Number new_value) { label.setText(greetings[new_value.intValue()]); } }); cb.setTooltip(new Tooltip("Select the language")); cb.setValue("English"); HBox hb = new HBox(); hb.getChildren().addAll(cb, label); hb.setSpacing(30); hb.setAlignment(Pos.CENTER); hb.setPadding(new Insets(10, 0, 0, 10)); ((Group) scene.getRoot()).getChildren().add(hb); }
From source file:vkmanager.controller.PhotosDetailedController.java
public void showPhotosFromAlbum(VKPhotoAlbum album, int userId) { this.album = album; idForDownload = album.getId();// w ww . j a va2 s .c o m albumDescription.setText(album.getDescription()); photos = vkapi.getPhotosFromAlbum(idForDownload, userId); int i = 0; int j = 0; gridPaneDetailed.addRow(0); for (VKPhoto photo : photos) { Image photoThumbLink = new Image(photo.getLink_s()); ImageView photoThumb = new ImageView(photoThumbLink); photoThumb.setFitHeight(160); photoThumb.setFitWidth(240); photoThumb.setPreserveRatio(true); photoThumb.setSmooth(true); photoThumb.setCache(true); Button photoButt = new Button(); photoButt.setGraphic(photoThumb); photoButt.setStyle("-fx-background-color: white;"); photoButt.setMinSize(240, 160); photoButt.setAlignment(Pos.CENTER); BorderPane bp = new BorderPane(null, photoButt, null, null, null); gridPaneDetailed.add(bp, j, i); j++; if (j == 3) { i++; j = 0; gridPaneDetailed.addRow(i); } } }
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);// w w w . j ava 2 s. c o m 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:FeeBooster.java
@Override public void start(Stage primaryStage) throws Exception { // Setup the stage stage = primaryStage;/*from w w w. jav a 2 s . co m*/ primaryStage.setTitle("Bitcoin Transaction Fee Booster"); // Setup intro gridpane GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); // Intro Text Text scenetitle = new Text( "Welcome to the fee booster. \n\nWhat type of transaction would you like to boost the fee of?"); grid.add(scenetitle, 0, 0, 2, 3); // radio button selections VBox boostRadioVbox = new VBox(); ToggleGroup boostTypeGroup = new ToggleGroup(); RadioButton rbfRadio = new RadioButton("A transaction you sent"); rbfRadio.setToggleGroup(boostTypeGroup); boostRadioVbox.getChildren().add(rbfRadio); RadioButton cpfpRadio = new RadioButton("A transaction you received"); cpfpRadio.setToggleGroup(boostTypeGroup); rbfRadio.setSelected(true); boostRadioVbox.getChildren().add(cpfpRadio); grid.add(boostRadioVbox, 0, 3); // Instructions Text Text instruct = new Text("Please enter the raw hex or transaction id of your transaction below:"); grid.add(instruct, 0, 4); // Textbox for hex of transaction TextArea txHexTxt = new TextArea(); txHexTxt.setWrapText(true); grid.add(txHexTxt, 0, 5, 5, 1); // Next Button Button nextBtn = new Button("Next"); nextBtn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { // Create Transaction Transaction tx = new Transaction(); // Check if txid boolean isTxid = txHexTxt.getText().length() == 64 && txHexTxt.getText().matches("[0-9A-Fa-f]+"); if (isTxid) tx.setHash(txHexTxt.getText()); // Determine which page to go to if (Transaction.deserializeStr(txHexTxt.getText(), tx) || isTxid) { // Get the fee JSONObject apiResult = Utils .getFromAnAPI("https://api.blockcypher.com/v1/btc/main/txs/" + tx.getHash(), "GET"); // Get the fee tx.setFee(apiResult.getInt("fees")); tx.setTotalAmtPre(tx.getFee() + tx.getOutAmt()); // Get info if txid if (isTxid) { } Scene scene = null; if (rbfRadio.isSelected()) if (sceneCursor == scenes.size() - 1 || !rbf) { scene = new Scene(rbfGrid(tx), 900, 500); if (!rbf) { scenes.clear(); scenes.add(stage.getScene()); } rbf = true; } if (cpfpRadio.isSelected()) if (sceneCursor == scenes.size() - 1 || rbf) { scene = new Scene(cpfpGrid(tx), 900, 500); if (rbf) { scenes.clear(); scenes.add(stage.getScene()); } rbf = false; } if (sceneCursor != scenes.size() - 1) scene = scenes.get(sceneCursor + 1); else scenes.add(scene); sceneCursor++; stage.setScene(scene); } else { Alert alert = new Alert(Alert.AlertType.ERROR, "Please enter a valid transaction"); alert.showAndWait(); } } }); HBox btnHbox = new HBox(10); btnHbox.getChildren().add(nextBtn); // Cancel Button Button cancelBtn = new Button("Cancel"); cancelBtn.setOnAction(cancelEvent); btnHbox.getChildren().add(cancelBtn); grid.add(btnHbox, 2, 7); // Display everything Scene scene = new Scene(grid, 900, 500); scenes.add(scene); primaryStage.setScene(scene); primaryStage.show(); }
From source file:guipart.AddMessageUploadFile.java
private void setScene(Stage window) { fileNames = new ArrayList<File>(); fileList = new ListView<String>(); files = FXCollections.observableArrayList(); fileList.setItems(files);//from w ww .ja v a 2 s . com fileList.setTranslateY(-50); fileList.setMaxWidth(300); fileList.setMinHeight(150); Label addMessagesLabel = new Label("Add messages"); Label loadedMessagesLabel = new Label("Loaded messages:"); Label imageLabel2 = new Label(); Image image2 = new Image(getClass().getResourceAsStream("/resources/gui/labelme_logo.png")); imageLabel2.setGraphic(new ImageView(image2)); imageLabel2.setPrefSize(200, 200); HBox imageBox2 = new HBox(); imageBox2.setAlignment(Pos.CENTER); imageBox2.setPadding(new Insets(20, 20, 20, 20)); imageBox2.getChildren().add(imageLabel2); acceptButton = new Button("Accept All"); browseButton = new Button("Browse"); finishButton = new Button("Finish"); previousButton = new Button("Previous"); cancelButton = new Button("X"); backButton = new Button("Back"); pathField.setMinWidth(200); textCategory = new Label(); addMessagesLabel.setFont(Font.font("Arial", FontWeight.BOLD, 28)); HBox hBox = new HBox(); hBox.setSpacing(20); hBox.getChildren().addAll(browseButton, pathField, acceptButton); hBox.setAlignment(Pos.CENTER); VBox layout = new VBox(); layout.setSpacing(30); VBox filesPlaceholder = new VBox(); filesPlaceholder.setSpacing(10); backButton.setTranslateY(-50); browseButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { //TODO: add more extensionFilters File currDir = new File("."); fileChooser.setInitialDirectory(currDir); fileChooser.getExtensionFilters().addAll((new FileChooser.ExtensionFilter("Text Files", "*.txt"))); File file = fileChooser.showOpenDialog(window); if (file != null) { pathField.setText(file.getName()); fileNames.add(file); files.add(file.getName()); } } }); fileList.setOnMouseClicked(e -> { //System.out.println(fileList.getSelectionModel().getSelectedItem()); files.remove(fileList.getSelectionModel().getSelectedItem()); for (File file : fileNames) { if (file.getName().equals(fileList.getSelectionModel().getSelectedItem())) { fileNames.remove(file); break; } } }); acceptButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { if (!fileNames.isEmpty()) { Categorize categorize = new Categorize(); categorize.trainModel(); int size = files.size(); for (int i = 0; i < size; i++) { String fileName = files.get(i); for (File file : fileNames) { if (file.getName().equals(fileName)) { try { files.add(fileName + " " + categorize.getCategory(FileUtils.readFileToString(file, "UTF-8"))); } catch (IOException ex) { Logger.getLogger(AddMessageUploadFile.class.getName()).log(Level.SEVERE, null, ex); } } } } int i = 0; while (i < size) { files.remove(0); i++; } /* try { textCategory.setText("The text category is: " + categorize.getCategory(FileUtils.readFileToString(fileNames.get(fileNames.size() - 1), "UTF-8"))); } catch (IOException ex) { Logger.getLogger(AddMessageUploadFile.class.getName()).log(Level.SEVERE, null, ex); }*/ } /* if (pathField.getText() != null) { int index = pathField.getText().lastIndexOf("\\"); Label messageLabel = new Label(pathField.getText().substring(index + 1)); messageLabel.setMinWidth(200); messageLabel.setMinHeight(25); messageLabel.setStyle("-fx-fill: orange;\n" + "-fx-border-color: blue;\n" + "-fx-border-width: 3;\n"); if (filesPlaceholder.getChildren().size() != 0) { layout.getChildren().remove(layout.getChildren().size() - 1); } filesPlaceholder.getChildren().addAll(messageLabel); filesPlaceholder.setAlignment(Pos.CENTER); filesPlaceholder.setPadding(new Insets(0, 0, 0, 50)); layout.getChildren().add(filesPlaceholder); }*/ } }); backButton.setOnAction(e -> { window.setScene(mainPage.mainPageScene); }); layout.getChildren().addAll(imageLabel2, addMessagesLabel, hBox, textCategory, fileList, backButton); layout.setStyle("-fx-background-color: white"); layout.setAlignment(Pos.TOP_CENTER); layout.setStyle("-fx-background-color: #B8EDFF;"); scene = new Scene(layout, 900, 600); }
From source file:mesclasses.objects.LoadWindow.java
private Scene createloadingScene() { bar = new ProgressBar(); vbox = new VBox(); BorderPane p = new BorderPane(); p.setCenter(bar);// w w w . ja v a2 s .c o m p.setTop(vbox); BorderPane.setAlignment(vbox, Pos.CENTER); return new Scene(p, 300, 150); }
From source file:com.bdb.weather.display.current.Hygrometer.java
/** * Constructor./* w w w . j a v a2s .com*/ * * @param titleString The title to add to the panel that contains the gauge */ public Hygrometer(String titleString) { this.setPrefSize(200.0, 200.0); ChartViewer chartViewer = createChartElements(); this.setTop(title); this.setCenter(chartViewer); BorderPane.setAlignment(title, Pos.CENTER); title.textProperty().bind(titleProperty); setTitle(titleString); }
From source file:org.sandsoft.acefx.AceEditor.java
/** * Creates a new instance of the ace editor. * * @return// ww w . jav a 2 s. co m * @throws java.io.IOException */ public static AceEditor createNew() throws IOException { //init loader FXMLLoader loader = new FXMLLoader(); loader.setLocation(AceEditor.class.getResource(AceEditor.class.getSimpleName() + ".fxml")); //attach node Node node = (Node) loader.load(); BorderPane.setAlignment(node, Pos.CENTER); AceEditor ace = (AceEditor) loader.getController(); ace.setCenter(node); ace.setMinSize(0, 0); ace.setPrefSize(600, 400); ace.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); //post load work ace.initialize(); return ace; }