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:com.playonlinux.ui.impl.javafx.mainwindow.center.ViewApps.java
private void initFailure() { failurePanel = new VBox(); failurePanel.getStyleClass().add("rightPane"); failurePanel.setSpacing(10);//from w w w. j a v a 2 s . c o m failurePanel.setAlignment(Pos.CENTER); Label failureNotificationLbl = new Label(); failureNotificationLbl.setText(translate( "Connecting to ${application.name} failed.\n" + "Please check your connection and try again.")); failureNotificationLbl.setTextAlignment(TextAlignment.CENTER); ImageView retryImage = new ImageView(new Image(getClass().getResourceAsStream("refresh.png"))); retryImage.setFitWidth(16); retryImage.setFitHeight(16); retryButton = new Button(translate("Retry"), retryImage); failurePanel.getChildren().addAll(failureNotificationLbl, retryButton); }
From source file:com.danilafe.sbaccountmanager.StarboundServerAccountManager.java
private void openAccountManager() { //Window Crap Stage accountManagerStage = new Stage(); accountManagerStage.setTitle("Starbound Server Account Manager"); GridPane gp = new GridPane(); gp.setAlignment(Pos.CENTER); gp.setVgap(10);//from ww w .j a va 2 s .co m gp.setHgap(10); gp.setPadding(new Insets(25, 25, 25, 25)); Text title = new Text("Starbound Account Manager"); title.setFont(Font.font("Century Gothic", FontWeight.NORMAL, 20)); gp.add(title, 0, 0, 2, 1); ListView<String> user_list = new ListView<String>(); ObservableList<String> user_list_o = FXCollections.observableArrayList(users); user_list.setItems(user_list_o); user_list.setPrefHeight(50); ListView<String> banned_users_list = new ListView<String>(); ObservableList<String> banned_users_list_o = FXCollections.observableArrayList(banned_usernames); banned_users_list.setItems(banned_users_list_o); banned_users_list.setPrefHeight(50); ListView<String> banned_ips_list = new ListView<String>(); ObservableList<String> banned_ips_list_o = FXCollections.observableArrayList(banned_ips); banned_ips_list.setItems(banned_ips_list_o); banned_ips_list.setPrefHeight(50); ListView<String> banned_playernames_list = new ListView<String>(); ObservableList<String> banned_playernames_list_o = FXCollections.observableArrayList(banned_playernames); banned_playernames_list.setItems(banned_playernames_list_o); banned_playernames_list.setPrefHeight(50); Label user_list_l = new Label("Current Users"); Label banned_users_list_l = new Label("Banned Users"); Label banned_ips_list_l = new Label("Banned IP's"); Label banned_playernames_list_l = new Label("Banned Player Names"); Button add_user = new Button("Add User"); Button add_banned_user = new Button("Add Banned User"); Button add_banned_ip = new Button("Add Banned IP"); Button add_banned_playername = new Button("Add Banner Playername"); Button remove_user = new Button("Remove User"); Button remove_banned_user = new Button("Remove Banned User"); Button remove_banned_ip = new Button("Remove Banned IP"); Button remove_banned_playername = new Button("Remove Banner Playername"); HBox userbox = new HBox(); userbox.setAlignment(Pos.BOTTOM_LEFT); userbox.getChildren().addAll(add_user, remove_user); userbox.setSpacing(5); HBox b_userbox = new HBox(); b_userbox.setAlignment(Pos.BOTTOM_LEFT); b_userbox.getChildren().addAll(add_banned_user, remove_banned_user); b_userbox.setSpacing(5); HBox b_ipbox = new HBox(); b_ipbox.setAlignment(Pos.BOTTOM_LEFT); b_ipbox.getChildren().addAll(add_banned_ip, remove_banned_ip); b_ipbox.setSpacing(5); HBox b_playerbox = new HBox(); b_playerbox.setAlignment(Pos.BOTTOM_LEFT); b_playerbox.getChildren().addAll(add_banned_playername, remove_banned_playername); b_playerbox.setSpacing(5); Button save = new Button("Save Config"); save.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { save(); } }); add_user.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { createAccount(user_list); } }); add_banned_user.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { createBannedUser(banned_users_list); } }); add_banned_ip.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { createBannedIP(banned_ips_list); } }); add_banned_playername.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { createBannedPlayername(banned_playernames_list); } }); remove_user.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { users.remove(user_list.getSelectionModel().getSelectedItem()); user_list.setItems(FXCollections.observableArrayList(users)); } }); remove_banned_user.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { banned_usernames.remove(banned_users_list.getSelectionModel().getSelectedItem()); banned_users_list.setItems(FXCollections.observableArrayList(banned_usernames)); } }); remove_banned_ip.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { banned_ips.remove(banned_ips_list.getSelectionModel().getSelectedItem()); banned_ips_list.setItems(FXCollections.observableArrayList(banned_ips)); } }); remove_banned_playername.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { banned_playernames.remove(banned_playernames_list.getSelectionModel().getSelectedItem()); banned_playernames_list.setItems(FXCollections.observableArrayList(banned_playernames)); } }); gp.add(user_list_l, 0, 1); gp.add(user_list, 0, 2); gp.add(userbox, 0, 3); gp.add(banned_users_list_l, 0, 4); gp.add(banned_users_list, 0, 5); gp.add(b_userbox, 0, 6); gp.add(banned_ips_list_l, 0, 7); gp.add(banned_ips_list, 0, 8); gp.add(b_ipbox, 0, 9); gp.add(banned_playernames_list_l, 0, 10); gp.add(banned_playernames_list, 0, 11); gp.add(b_playerbox, 0, 12); gp.add(save, 0, 13); Scene sc = new Scene(gp, 800 / 2, 600); accountManagerStage.setScene(sc); accountManagerStage.show(); }
From source file:com.bdb.weather.display.current.Thermometer.java
/** * Constructor.// www. java2 s.c om * * @param title The title to display in the containing panel * @param min The minimum value for the thermometer scale * @param max The maximum value for the thermometer scale */ public Thermometer(String title, Temperature min, Temperature max) { this.setPrefSize(150.0, 200.0); minValue = min; maxValue = max; unitProperty.setValue(Temperature.getDefaultUnit()); setUnits(unitProperty.getValue()); ChartViewer chartViewer = createChartElements(); this.setCenter(chartViewer); HBox p = new HBox(); p.setAlignment(Pos.CENTER); Label label = new Label("High: "); label.setStyle("-fx-font-weight: bold"); p.getChildren().addAll(label, highLabel); this.setTop(p); p = new HBox(); p.setAlignment(Pos.CENTER); label = new Label("Low: "); label.setStyle("-fx-font-weight: bold"); p.getChildren().addAll(label, lowLabel); this.setBottom(p); unitProperty.addListener((ObservableValue<? extends Temperature.Unit> observable, Temperature.Unit oldValue, Temperature.Unit newValue) -> { setUnits(newValue); }); }
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);// w ww . j av a2 s.com 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:fruitproject.FruitProject.java
public void first(final Stage primaryStage) { GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER); grid.setHgap(10);/*ww w. j a v a 2 s .c o 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:at.ac.tuwien.qse.sepm.gui.control.ImageTile.java
public ImageTile() { getStyleClass().add("imageTile"); Group overlay = new Group(); HBox overlayBox = new HBox(); overlayBox.getStyleClass().add("hoverlay"); overlayBox.getChildren().addAll(overLayIcon, name); overlay.getChildren().add(overlayBox); StackPane.setAlignment(overlay, Pos.CENTER); placeHolder.setGlyphSize(ImageSize.LARGE.pixels() * 0.6); setMinHeight(0);//from w ww . j av a 2s .c om setMinWidth(0); imageView.setPreserveRatio(false); getChildren().add(placeHolder); getChildren().add(imageView); getChildren().add(overlay); setAlignment(overlay, Pos.CENTER); setOnMouseEntered((event) -> { if (photos.size() > 0) { setCursor(Cursor.HAND); } }); setOnMouseExited((event -> setCursor(Cursor.DEFAULT))); imageView.visibleProperty().bind(photosProperty.emptyProperty().not()); overlay.visibleProperty().bind(photosProperty.emptyProperty().not().and(name.textProperty().isNotEmpty())); placeHolder.visibleProperty().bind(photosProperty.emptyProperty()); heightProperty().addListener(this::handleSizeChange); widthProperty().addListener(this::handleSizeChange); }
From source file:net.thirdy.blackmarket.controls.ModSelectionPane.java
public ModSelectionPane() { setHgap(5.0);/*from w ww.j a va 2 s .com*/ setMaxHeight(Double.MAX_VALUE); setMinHeight(560); setAlignment(Pos.CENTER); setupModListView(); accept(Collections.emptyList()); setupModMappingTable(); setupFilterTextField(); tfMinShouldMatch = new DoubleTextField("Minimum number of OR modifiers to match"); tfMinShouldMatch.setMinWidth(350); Button add = addButton(); add.setPrefWidth(150); HBox hBox = new HBox(5, new Label("Filter: "), filterField, add); hBox.setAlignment(Pos.CENTER); VBox.setVgrow(modMappingTable, Priority.ALWAYS); VBox left = new VBox(10, hBox, modMappingTable); VBox.setVgrow(modsListView, Priority.ALWAYS); Label modifiersLbl = new Label("Modifiers"); modifiersLbl.setFont(Font.font("Verdana", FontWeight.MEDIUM, 14)); modifiersLbl.setPadding(new Insets(4)); HBox minShouldMatchHBox = new HBox(3, new Label("Minimum OR Matches:"), tfMinShouldMatch); minShouldMatchHBox.setAlignment(Pos.CENTER); VBox right = new VBox(3, new StackPane(modifiersLbl), minShouldMatchHBox, modsListView); setupGridPaneColumns(); GridPane.setVgrow(left, Priority.ALWAYS); GridPane.setVgrow(right, Priority.ALWAYS); add(left, 0, 0); add(right, 1, 0); }
From source file:nl.mvdr.umvc3replayanalyser.gui.ErrorMessagePopup.java
/** * Handles an exception that caused program startup to fail, by showing an error message to the user. * /*from w ww. j a va 2 s . c o m*/ * @param title * title for the dialog * @param errorMessage * error message * @param stage * stage in which to show the error message * @param exception * exception that caused the error */ public static void show(String title, String errorMessage, final Stage stage, Exception exception) { log.info("Showing error message dialog to indicate that startup failed."); // Create the error dialog programatically without relying on FXML, to minimize the chances of further failure. stage.setTitle(title); // Error message text. Text text = new Text(errorMessage); // Text area containing the stack trace. Not visible by default. String stackTrace; if (exception != null) { stackTrace = ExceptionUtils.getStackTrace(exception); } else { stackTrace = "No more details available."; } final TextArea stackTraceArea = new TextArea(stackTrace); stackTraceArea.setEditable(false); stackTraceArea.setVisible(false); // Details button for displaying the stack trace. Button detailsButton = new Button(); detailsButton.setText("Details"); detailsButton.setOnAction(new EventHandler<ActionEvent>() { /** {@inheritDoc} */ @Override public void handle(ActionEvent event) { log.info("User clicked Details."); stackTraceArea.setVisible(!stackTraceArea.isVisible()); } }); // OK button for closing the dialog. Button okButton = new Button(); okButton.setText("OK"); okButton.setOnAction(new EventHandler<ActionEvent>() { /** {@inheritDoc} */ @Override public void handle(ActionEvent event) { log.info("User clicked OK, closing the dialog."); stage.close(); } }); // Horizontal box containing the buttons, to make sure they are always centered. HBox buttonsBox = new HBox(5); buttonsBox.getChildren().add(detailsButton); buttonsBox.getChildren().add(okButton); buttonsBox.setAlignment(Pos.CENTER); // Layout constraints. AnchorPane.setTopAnchor(text, Double.valueOf(5)); AnchorPane.setLeftAnchor(text, Double.valueOf(5)); AnchorPane.setRightAnchor(text, Double.valueOf(5)); AnchorPane.setTopAnchor(stackTraceArea, Double.valueOf(31)); AnchorPane.setLeftAnchor(stackTraceArea, Double.valueOf(5)); AnchorPane.setRightAnchor(stackTraceArea, Double.valueOf(5)); AnchorPane.setBottomAnchor(stackTraceArea, Double.valueOf(36)); AnchorPane.setLeftAnchor(buttonsBox, Double.valueOf(5)); AnchorPane.setRightAnchor(buttonsBox, Double.valueOf(5)); AnchorPane.setBottomAnchor(buttonsBox, Double.valueOf(5)); AnchorPane root = new AnchorPane(); root.getChildren().addAll(text, stackTraceArea, buttonsBox); stage.setScene(new Scene(root)); // Use a standard program icon if possible. try { stage.getIcons().add(Icons.get().getRandomPortrait()); } catch (IllegalStateException e) { log.warn("Failed to load icon for error dialog; proceeding with default JavaFX icon.", e); } stage.show(); // Default size should also be the minimum size. stage.setMinWidth(stage.getWidth()); stage.setMinHeight(stage.getHeight()); log.info("Error dialog displayed."); }
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 ww w . j a v a 2 s . co 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:MediaControl.java
public MediaControl(final MediaPlayer mp) { this.mp = mp; setStyle("-fx-background-color: #bfc2c7;"); mediaView = new MediaView(mp); Pane mvPane = new Pane() { };/* w w w . ja v a 2 s.com*/ mvPane.getChildren().add(mediaView); mvPane.setStyle("-fx-background-color: black;"); setCenter(mvPane); mediaBar = new HBox(); mediaBar.setAlignment(Pos.CENTER); mediaBar.setPadding(new Insets(5, 10, 5, 10)); BorderPane.setAlignment(mediaBar, Pos.CENTER); final Button playButton = new Button(">"); playButton.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent e) { Status status = mp.getStatus(); if (status == Status.UNKNOWN || status == Status.HALTED) { // don't do anything in these states return; } if (status == Status.PAUSED || status == Status.READY || status == Status.STOPPED) { // rewind the movie if we're sitting at the end if (atEndOfMedia) { mp.seek(mp.getStartTime()); atEndOfMedia = false; } mp.play(); } else { mp.pause(); } } }); mp.currentTimeProperty().addListener(new InvalidationListener() { public void invalidated(Observable ov) { updateValues(); } }); mp.setOnPlaying(new Runnable() { public void run() { if (stopRequested) { mp.pause(); stopRequested = false; } else { playButton.setText("||"); } } }); mp.setOnPaused(new Runnable() { public void run() { System.out.println("onPaused"); playButton.setText(">"); } }); mp.setOnReady(new Runnable() { public void run() { duration = mp.getMedia().getDuration(); updateValues(); } }); mp.setCycleCount(repeat ? MediaPlayer.INDEFINITE : 1); mp.setOnEndOfMedia(new Runnable() { public void run() { if (!repeat) { playButton.setText(">"); stopRequested = true; atEndOfMedia = true; } } }); mediaBar.getChildren().add(playButton); // Add spacer Label spacer = new Label(" "); mediaBar.getChildren().add(spacer); // Add Time label Label timeLabel = new Label("Time: "); mediaBar.getChildren().add(timeLabel); // Add time slider timeSlider = new Slider(); HBox.setHgrow(timeSlider, Priority.ALWAYS); timeSlider.setMinWidth(50); timeSlider.setMaxWidth(Double.MAX_VALUE); timeSlider.valueProperty().addListener(new InvalidationListener() { public void invalidated(Observable ov) { if (timeSlider.isValueChanging()) { // multiply duration by percentage calculated by slider position mp.seek(duration.multiply(timeSlider.getValue() / 100.0)); } } }); mediaBar.getChildren().add(timeSlider); // Add Play label playTime = new Label(); playTime.setPrefWidth(130); playTime.setMinWidth(50); mediaBar.getChildren().add(playTime); // Add the volume label Label volumeLabel = new Label("Vol: "); mediaBar.getChildren().add(volumeLabel); // Add Volume slider volumeSlider = new Slider(); volumeSlider.setPrefWidth(70); volumeSlider.setMaxWidth(Region.USE_PREF_SIZE); volumeSlider.setMinWidth(30); volumeSlider.valueProperty().addListener(new InvalidationListener() { public void invalidated(Observable ov) { if (volumeSlider.isValueChanging()) { mp.setVolume(volumeSlider.getValue() / 100.0); } } }); mediaBar.getChildren().add(volumeSlider); setBottom(mediaBar); }