List of usage examples for javafx.scene.layout Priority ALWAYS
Priority ALWAYS
To view the source code for javafx.scene.layout Priority ALWAYS.
Click Source Link
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);//from ww w. j a v a 2s .c o m 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); Label candidatesLbl = new Label("Candidates"); GridPane.setHalignment(candidatesLbl, HPos.CENTER); gridpane.add(candidatesLbl, 0, 0); Label selectedLbl = new Label("selected"); gridpane.add(selectedLbl, 2, 0); GridPane.setHalignment(selectedLbl, HPos.CENTER); // Candidates final ObservableList<String> candidates = FXCollections.observableArrayList("Z", "A", "B", "C", "D"); final ListView<String> candidatesListView = new ListView<>(candidates); gridpane.add(candidatesListView, 0, 1); final ObservableList<String> selected = FXCollections.observableArrayList(); final ListView<String> heroListView = new ListView<>(selected); 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); selected.add(potential); } }); Button sendLeftButton = new Button(" < "); sendLeftButton.setOnAction((ActionEvent event) -> { String s = heroListView.getSelectionModel().getSelectedItem(); if (s != null) { heroListView.getSelectionModel().clearSelection(); selected.remove(s); candidates.add(s); } }); VBox vbox = new VBox(5); vbox.getChildren().addAll(sendRightButton, sendLeftButton); gridpane.add(vbox, 1, 1); root.setCenter(gridpane); GridPane.setVgrow(root, Priority.ALWAYS); primaryStage.setScene(scene); primaryStage.show(); }
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);//from w w w . j a v a 2s .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:Main.java
private VBox getCenter() { Label nameLbl = new Label("Name:"); TextField nameFld = new TextField(); HBox.setHgrow(nameFld, Priority.ALWAYS); HBox nameFields = new HBox(nameLbl, nameFld); Label descLbl = new Label("Description:"); TextArea descText = new TextArea(); descText.setPrefColumnCount(20);//from www . j ava 2 s . c om descText.setPrefRowCount(5); VBox.setVgrow(descText, Priority.ALWAYS); VBox center = new VBox(nameFields, descLbl, descText); return center; }
From source file:Main.java
@Override public void start(Stage primaryStage) { TextArea myTextArea = new TextArea(); VBox hbox = new VBox(); hbox.getChildren().add(myTextArea); VBox.setVgrow(myTextArea, Priority.ALWAYS); Scene scene = new Scene(hbox, 320, 112, Color.rgb(0, 0, 0, 0)); primaryStage.setScene(scene);// www. j av a2 s .com primaryStage.show(); }
From source file:org.pdfsam.ui.banner.BannerPane.java
@Inject public BannerPane(BannerButtons buttons, ImageView payoff, @Named("logo32") Image logo) { getStyleClass().add("pdfsam-banner"); current.getStyleClass().add("header-title"); HBox.setHgrow(buttons, Priority.ALWAYS); HBox logoView = new HBox(); logoView.getStyleClass().add("pdfsam-logo"); logoView.getChildren().addAll(new ImageView(logo), payoff); getChildren().addAll(logoView, current, buttons); eventStudio().addAnnotatedListeners(this); }
From source file:org.pdfsam.ui.prefix.PrefixPane.java
public PrefixPane() { getStyleClass().addAll(Style.CONTAINER.css()); getStyleClass().addAll(Style.HCONTAINER.css()); VBox.setVgrow(field, Priority.ALWAYS); getChildren().addAll(//from www .j a v a2s.c o m new Label(DefaultI18nContext.getInstance().i18n("Generated pdf documents name prefix:")), field); }
From source file:org.pdfsam.ui.io.BrowsableField.java
public BrowsableField() { HBox.setHgrow(textField, Priority.ALWAYS); this.getStyleClass().add("browsable-field"); validableContainer = new HBox(textField); validableContainer.getStyleClass().add("validable-container"); textField.getStyleClass().add("validable-container-field"); browseButton = new Button(DefaultI18nContext.getInstance().i18n("Browse")); browseButton.getStyleClass().addAll(Style.BROWSE_BUTTON.css()); browseButton.prefHeightProperty().bind(validableContainer.heightProperty()); browseButton.setMaxHeight(USE_PREF_SIZE); browseButton.setMinHeight(USE_PREF_SIZE); HBox.setHgrow(validableContainer, Priority.ALWAYS); textField.validProperty().addListener((o, oldValue, newValue) -> { if (newValue == ValidationState.INVALID) { validableContainer.getStyleClass().addAll(Style.INVALID.css()); } else {// w w w. ja v a 2 s. c om validableContainer.getStyleClass().removeAll(Style.INVALID.css()); } }); textField.focusedProperty().addListener((o, oldVal, newVal) -> validableContainer .pseudoClassStateChanged(SELECTED_PSEUDOCLASS_STATE, newVal)); getChildren().addAll(validableContainer, browseButton); }
From source file:org.pdfsam.ui.dashboard.preference.PreferenceWorkspacePane.java
@Inject public PreferenceWorkspacePane(@Named("workingDirectory") PreferenceBrowsableDirectoryField workingDirectory, @Named("workspace") PreferenceBrowsableFileField workspace, @Named("saveWorkspaceOnExit") PreferenceCheckBox saveWorkspaceOnExit) { I18nContext i18n = DefaultI18nContext.getInstance(); workingDirectory.getTextField()//from w w w. ja va2s . c o m .setPromptText(i18n.i18n("Select a directory where documents will be saved and loaded by default")); workingDirectory.setBrowseWindowTitle(i18n.i18n("Select a directory")); HBox workigDirPane = new HBox(workingDirectory, helpIcon(i18n.i18n("Select a directory where documents will be saved and loaded by default"))); HBox.setHgrow(workingDirectory, Priority.ALWAYS); workigDirPane.getStyleClass().add("with-help-hcontainer"); workspace.getTextField().setPromptText( i18n.i18n("Select a previously saved workspace that will be automatically loaded at startup")); workspace.setBrowseWindowTitle(i18n.i18n("Select a workspace")); HBox workspaceDirPane = new HBox(workspace, helpIcon( i18n.i18n("Select a previously saved workspace that will be automatically loaded at startup"))); HBox.setHgrow(workspace, Priority.ALWAYS); workspaceDirPane.getStyleClass().add("with-help-hcontainer"); workspace.getTextField().validProperty().addListener((o, oldVal, newVal) -> { saveWorkspaceOnExit .setDisable(isBlank(workspace.getTextField().getText()) || newVal != ValidationState.VALID); }); workspace.getTextField().validate(); getChildren().addAll(new Label(i18n.i18n("Default working directory:")), workigDirPane, new Label(i18n.i18n("Load default workspace at startup:")), workspaceDirPane, saveWorkspaceOnExit); getStyleClass().addAll(Style.CONTAINER.css()); }
From source file:org.jacp.demo.components.ContactAddDialog.java
private void createAddContactDialog() { final VBox box = new VBox(); box.getStyleClass().add("jacp-option-pane"); box.setMaxSize(300, Region.USE_PREF_SIZE); // the title//from w w w .j av a 2 s . c o m final Label title = new Label("Add new category"); title.setId(GlobalConstants.CSSConstants.ID_JACP_CUSTOM_TITLE); VBox.setMargin(title, new Insets(2, 2, 10, 2)); final HBox hboxInput = new HBox(); final Label nameLabel = new Label("category name:"); HBox.setMargin(nameLabel, new Insets(2)); final TextField nameInput = new TextField(); HBox.setMargin(nameInput, new Insets(0, 0, 0, 5)); HBox.setHgrow(nameInput, Priority.ALWAYS); hboxInput.getChildren().addAll(nameLabel, nameInput); final HBox hboxButtons = new HBox(); hboxButtons.setAlignment(Pos.CENTER_RIGHT); final Button ok = new Button("OK"); HBox.setMargin(ok, new Insets(6, 5, 4, 2)); final Button cancel = new Button("Cancel"); HBox.setMargin(cancel, new Insets(6, 2, 4, 5)); cancel.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(final ActionEvent arg0) { JACPModalDialog.getInstance().hideModalDialog(); } }); ok.setDefaultButton(true); ok.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(final ActionEvent actionEvent) { final String catName = nameInput.getText(); if (catName != null && StringUtils.hasText(catName)) { // contacts final Contact contact = new Contact(); contact.setFirstName(catName); parent.getContext().send(contact); JACPModalDialog.getInstance().hideModalDialog(); } } }); hboxButtons.getChildren().addAll(ok, cancel); box.getChildren().addAll(title, hboxInput, hboxButtons); JACPModalDialog.getInstance().showModalDialog(box); }
From source file:org.mskcc.shenkers.control.alignment.AlignmentOverlay.java
private void populateGridPane() { ObservableList<Node> children = this.getChildren(); children.clear();/*from w w w. ja va 2 s . co m*/ int l = nodes.size(); boolean flip = flipProperty.get(); for (int i = 0; i < l; i++) { Node n = nodes.get(i); GridPane.setHalignment(n, HPos.CENTER); GridPane.setValignment(n, VPos.CENTER); GridPane.setHgrow(n, Priority.ALWAYS); GridPane.setVgrow(n, Priority.ALWAYS); GridPane.setRowIndex(n, 0); GridPane.setColumnIndex(n, flip ? l - i - 1 : i); children.add(n); } }