Java Code Examples for javafx.scene.layout.ColumnConstraints#setPercentWidth()
The following examples show how to use
javafx.scene.layout.ColumnConstraints#setPercentWidth() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EasyGridPane.java From constellation with Apache License 2.0 | 6 votes |
public void addColumnConstraint(boolean fillWidth, HPos alignment, Priority grow, double maxWidth, double minWidth, double prefWidth, double percentWidth) { ColumnConstraints constraint = new ColumnConstraints(); constraint.setFillWidth(fillWidth); constraint.setHalignment(alignment); constraint.setHgrow(grow); constraint.setMaxWidth(maxWidth); constraint.setMinWidth(minWidth); constraint.setPrefWidth(prefWidth); if (percentWidth >= 0) { constraint.setPercentWidth(percentWidth); } getColumnConstraints().add(constraint); }
Example 2
Source File: JFXHelper.java From Schillsaver with MIT License | 6 votes |
/** * Creates a GridPane with only one row, but where there are as many equal sized columns as there are * controls passed to the function. * * Ex: * If you pass in two controls, then there will be one row with two columns where each column uses * 50% of the width. * * Ex: * If you pass in four controls, then there will be one row with four columns where each column uses * 25% of the width. * * @param controls * The controls. * * @return * The pane. */ public static GridPane createHorizontalGridPane(final Control... controls) { if (controls.length == 0) { return new GridPane(); } final GridPane pane = new GridPane(); final double sectionWidth = 100.0 / controls.length; for (final Control ignored : controls) { final ColumnConstraints constraints = new ColumnConstraints(); constraints.setPercentWidth(sectionWidth); pane.getColumnConstraints().add(constraints); } for (int i = 0 ; i < controls.length ; i++) { pane.add(controls[i], i, 0); } return pane; }
Example 3
Source File: ProposalDisplay.java From bisq with GNU Affero General Public License v3.0 | 6 votes |
@SuppressWarnings("Duplicates") public ScrollPane getView() { ScrollPane scrollPane = new ScrollPane(); scrollPane.setFitToWidth(true); scrollPane.setFitToHeight(true); AnchorPane anchorPane = new AnchorPane(); scrollPane.setContent(anchorPane); gridPane.setHgap(5); gridPane.setVgap(5); ColumnConstraints columnConstraints1 = new ColumnConstraints(); columnConstraints1.setPercentWidth(100); gridPane.getColumnConstraints().addAll(columnConstraints1); AnchorPane.setBottomAnchor(gridPane, 10d); AnchorPane.setRightAnchor(gridPane, 10d); AnchorPane.setLeftAnchor(gridPane, 10d); AnchorPane.setTopAnchor(gridPane, 10d); anchorPane.getChildren().add(gridPane); return scrollPane; }
Example 4
Source File: RuleContainer.java From G-Earth with MIT License | 5 votes |
private void initialize() { RowConstraints rowConstraints = new RowConstraints(23); getRowConstraints().addAll(rowConstraints); for (int i = 0; i < columnWidths.length; i++) { ColumnConstraints columnConstraints = new ColumnConstraints(20); columnConstraints.setPercentWidth(columnWidths[i]); getColumnConstraints().add(columnConstraints); } Label optionLabel = initNewLabelColumn(item.option().name()); Label typeLabel = initNewLabelColumn(item.type().name()); Label valueLabel = initNewLabelColumn(item.value()); Label replacementLabel = initNewLabelColumn(item.replacement()); Label destinationLabel = initNewLabelColumn(item.side().name()); add(optionLabel, 0, 0); add(typeLabel, 1, 0); add(valueLabel, 2, 0); add(replacementLabel, 3, 0); add(destinationLabel, 4, 0); DeleteButton deleteButton = new DeleteButton(); deleteButton.setAlignment(Pos.CENTER); deleteButton.show(); RuleContainer thiss = this; item.onDelete(observable -> parent.getChildren().remove(thiss)); deleteButton.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> item.delete()); add(deleteButton, 5, 0); parent.getChildren().add(this); }
Example 5
Source File: Util.java From pattypan with MIT License | 5 votes |
public static ColumnConstraints newColumn(int value, String unit, HPos position) { ColumnConstraints col = new ColumnConstraints(); if (unit.equals("%")) { col.setPercentWidth(value); } if (unit.equals("px")) { col.setMaxWidth(value); col.setMinWidth(value); } if (position != null) { col.setHalignment(position); } return col; }
Example 6
Source File: MdConvertController.java From zest-writer with GNU General Public License v3.0 | 5 votes |
public void initStats() { String fontSize="-fx-font-size: 0.9em;"; getMdBox().getMainApp().getMenuController().getHBottomBox().getChildren().clear(); getMdBox().getMainApp().getMenuController().getHBottomBox().getColumnConstraints().clear(); getMdBox().getMainApp().getMenuController().getHBottomBox().setPadding(new Insets(5, 5, 5, 5)); ColumnConstraints c1 = new ColumnConstraints(); ColumnConstraints c2 = new ColumnConstraints(); ColumnConstraints c3 = new ColumnConstraints(); ColumnConstraints c4 = new ColumnConstraints(); c1.setPercentWidth(50); c2.setPercentWidth(20); c3.setPercentWidth(15); c4.setPercentWidth(15); Label chars = new Label(); Label words = new Label(); Label times = new Label(); chars.setStyle(fontSize); words.setStyle(fontSize); times.setStyle(fontSize); getMdBox().getMainApp().getMenuController().getHBottomBox().getColumnConstraints().addAll(c1, c2, c3, c4); getMdBox().getMainApp().getMenuController().getHBottomBox().add(times, 1, 0); getMdBox().getMainApp().getMenuController().getHBottomBox().add(chars, 2, 0); getMdBox().getMainApp().getMenuController().getHBottomBox().add(words, 3, 0); chars.textProperty().bind(countChars); words.textProperty().bind(countWords); times.textProperty().bind(countTimes); performStats(); }
Example 7
Source File: GUIController.java From density-converter with Apache License 2.0 | 5 votes |
private void setupLayout() { ColumnConstraints column1M = new ColumnConstraints(); column1M.setPercentWidth(20); ColumnConstraints column2M = new ColumnConstraints(); column2M.setPercentWidth(56); ColumnConstraints column3M = new ColumnConstraints(); column3M.setPercentWidth(12); ColumnConstraints column4M = new ColumnConstraints(); column4M.setPercentWidth(12); rootGridPane.getColumnConstraints().addAll(column1M, column2M, column3M, column4M); ColumnConstraints column1 = new ColumnConstraints(); column1.setPercentWidth(20); ColumnConstraints column2 = new ColumnConstraints(); column2.setPercentWidth(30); ColumnConstraints column3 = new ColumnConstraints(); column3.setPercentWidth(20); ColumnConstraints column4 = new ColumnConstraints(); column4.setPercentWidth(30); gridPaneChoiceBoxes.getColumnConstraints().addAll(column1, column2, column3, column4); ColumnConstraints column1C = new ColumnConstraints(); column1C.setPercentWidth(50); ColumnConstraints column2C = new ColumnConstraints(); column2C.setPercentWidth(50); gridPaneOptionsCheckboxes.getColumnConstraints().addAll(column1C, column2C); gridPanePostProcessors.getColumnConstraints().addAll(column1C, column2C); ColumnConstraints column1D = new ColumnConstraints(); column1D.setPercentWidth(25); ColumnConstraints column2D = new ColumnConstraints(); column2D.setPercentWidth(25); ColumnConstraints column3D = new ColumnConstraints(); column3D.setPercentWidth(25); ColumnConstraints column4D = new ColumnConstraints(); column4D.setPercentWidth(25); gridPaneToggleGroup.getColumnConstraints().addAll(column1D, column2D, column3D, column4D); }
Example 8
Source File: CodePane.java From JRemapper with MIT License | 5 votes |
/** * Setup everything else that isn't the code-area. */ private void setupTheRest() { info.setPrefHeight(95); info.getStyleClass().add("infopane"); ColumnConstraints colInfo = new ColumnConstraints(); ColumnConstraints colEdit = new ColumnConstraints(); colInfo.setPercentWidth(15); colEdit.setPercentWidth(85); info.getColumnConstraints().addAll(colInfo, colEdit); setTop(info); pane.animationDurationProperty().setValue(Duration.millis(50)); pane.setContent(new VirtualizedScrollPane<>(code)); setCenter(pane); }
Example 9
Source File: ProofOfBurnVerificationWindow.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
@SuppressWarnings("Duplicates") @Override protected void createGridPane() { gridPane = new GridPane(); gridPane.setHgap(5); gridPane.setVgap(5); gridPane.setPadding(new Insets(64, 64, 64, 64)); gridPane.setPrefWidth(width); ColumnConstraints columnConstraints = new ColumnConstraints(); columnConstraints.setPercentWidth(100); gridPane.getColumnConstraints().add(columnConstraints); }
Example 10
Source File: ProofOfBurnSignatureWindow.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
@SuppressWarnings("Duplicates") @Override protected void createGridPane() { gridPane = new GridPane(); gridPane.setHgap(5); gridPane.setVgap(5); gridPane.setPadding(new Insets(64, 64, 64, 64)); gridPane.setPrefWidth(width); ColumnConstraints columnConstraints = new ColumnConstraints(); columnConstraints.setPercentWidth(100); gridPane.getColumnConstraints().add(columnConstraints); }
Example 11
Source File: BaseInfoTab.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
BaseInfoTab() { setClosable(false); grid.getStyleClass().add("info-props"); grid.setAlignment(Pos.TOP_CENTER); ColumnConstraints column1 = new ColumnConstraints(); column1.setPercentWidth(25); ColumnConstraints column2 = new ColumnConstraints(); column2.setPercentWidth(75); grid.getColumnConstraints().addAll(column1, column2); ScrollPane scroll = new ScrollPane(grid); scroll.setFitToHeight(true); scroll.setFitToWidth(true); setContent(scroll); }
Example 12
Source File: TilingPane.java From chart-fx with Apache License 2.0 | 4 votes |
protected void layoutNormal() { if (getChildren().isEmpty()) { return; } final int colsCount = getColumnsCount(); if (getColumnConstraints().size() != colsCount) { final List<ColumnConstraints> colConstraintList = new ArrayList<>(); for (int i = 0; i < colsCount; i++) { final ColumnConstraints colConstraints = new ColumnConstraints(); // NOPMD colConstraints.setPercentWidth(100.0 / colsCount); colConstraints.setFillWidth(true); colConstraintList.add(colConstraints); } getColumnConstraints().setAll(colConstraintList); } int rowIndex = 0; int colIndex = 0; int childCount = 0; final int nChildren = getChildren().size(); int nColSpan = Math.max(1, colsCount / (nChildren - childCount)); for (final Node child : getChildren()) { GridPane.setFillWidth(child, true); GridPane.setFillHeight(child, true); GridPane.setColumnIndex(child, colIndex); GridPane.setRowIndex(child, rowIndex); if ((colIndex == 0) && ((nChildren - childCount) < colsCount)) { nColSpan = Math.max(1, colsCount / (nChildren - childCount)); } // last window fills up row if (((nChildren - childCount) == 1) && (colIndex < colsCount)) { nColSpan = colsCount - colIndex; } GridPane.setColumnSpan(child, nColSpan); colIndex += nColSpan; if (colIndex >= colsCount) { colIndex = 0; rowIndex++; } childCount++; } }
Example 13
Source File: SelectSongsDialog.java From Quelea with GNU General Public License v3.0 | 4 votes |
/** * Set the songs to be shown in the dialog. * <p/> * @param songs the list of songs to be shown. * @param checkList a list corresponding to the song list - each position is * true if the checkbox should be selected, false otherwise. * @param defaultVal the default value to use for the checkbox if checkList * is null or smaller than the songs list. */ public void setSongs(final List<SongDisplayable> songs, final Map<SongDisplayable, Boolean> checkList, final boolean defaultVal) { this.songs = songs; gridPane.getChildren().clear(); checkBoxes.clear(); gridPane.getColumnConstraints().add(new ColumnConstraints(20)); ColumnConstraints titleConstraints = new ColumnConstraints(); titleConstraints.setHgrow(Priority.ALWAYS); titleConstraints.setPercentWidth(50); gridPane.getColumnConstraints().add(titleConstraints); ColumnConstraints authorConstraints = new ColumnConstraints(); authorConstraints.setHgrow(Priority.ALWAYS); authorConstraints.setPercentWidth(45); gridPane.getColumnConstraints().add(authorConstraints); Label titleHeader = new Label(LabelGrabber.INSTANCE.getLabel("title.label")); titleHeader.setAlignment(Pos.CENTER); Label authorHeader = new Label(LabelGrabber.INSTANCE.getLabel("author.label")); authorHeader.setAlignment(Pos.CENTER); gridPane.add(titleHeader, 1, 0); gridPane.add(authorHeader, 2, 0); for(int i = 0; i < songs.size(); i++) { SongDisplayable song = songs.get(i); CheckBox checkBox = new CheckBox(); checkBox.selectedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) { checkEnableButton(); } }); if(checkList != null) { final Boolean result = checkList.get(song); if(result!=null) { checkBox.setSelected(!result); } } checkBoxes.add(checkBox); gridPane.add(checkBox, 0, i + 1); gridPane.add(new Label(song.getTitle()), 1, i + 1); gridPane.add(new Label(song.getAuthor()), 2, i + 1); } for(int i = 0; i < 2; i++) { Node n = gridPane.getChildren().get(i); if(n instanceof Control) { Control control = (Control) n; control.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); control.setStyle("-fx-alignment: center;-fx-font-weight: bold;"); } if(n instanceof Pane) { Pane pane = (Pane) n; pane.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); pane.setStyle("-fx-alignment: center;-fx-font-weight: bold;"); } } gridScroll.setVvalue(0); checkEnableButton(); }
Example 14
Source File: ScatterPlot3DFXDemo3.java From jfree-fxdemos with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Returns a panel containing the content for the demo. This method is * used across all the individual demo applications to allow aggregation * into a single "umbrella" demo (OrsonChartsDemo). * * @return A panel containing the content for the demo. */ public static Node createDemoNode() { XYZDataset[] datasets = createDatasets(); Chart3D chart1 = createChart( "Iris Dataset : Combination 1", datasets[0], "Sepal Length", "Sepal Width", "Petal Length"); chart1.setViewPoint(ViewPoint3D.createAboveLeftViewPoint(120)); Chart3DViewer viewer1 = new Chart3DViewer(chart1); Chart3D chart2 = createChart( "Iris Dataset : Combination 2", datasets[1], "Sepal Length", "Sepal Width", "Petal Width"); chart2.setViewPoint(ViewPoint3D.createAboveLeftViewPoint(120)); Chart3DViewer viewer2 = new Chart3DViewer(chart2); Chart3D chart3 = createChart( "Iris Dataset : Combination 3", datasets[2], "Sepal Length", "Petal Width", "Petal Length"); chart3.setViewPoint(ViewPoint3D.createAboveLeftViewPoint(120)); Chart3DViewer viewer3 = new Chart3DViewer(chart3); Chart3D chart4 = createChart( "Iris Dataset : Combination 4", datasets[3], "Sepal Width", "Petal Width", "Petal Length"); chart4.setViewPoint(ViewPoint3D.createAboveLeftViewPoint(120)); Chart3DViewer viewer4 = new Chart3DViewer(chart4); GridPane pane = new GridPane(); ColumnConstraints c1 = new ColumnConstraints(); c1.setPercentWidth(50); ColumnConstraints c2 = new ColumnConstraints(); c2.setPercentWidth(50); pane.getColumnConstraints().addAll(c1, c2); RowConstraints r1 = new RowConstraints(); r1.setPercentHeight(50); RowConstraints r2 = new RowConstraints(); r2.setPercentHeight(50); pane.getRowConstraints().addAll(r1, r2); pane.add(viewer1, 0, 0); pane.add(viewer2, 0, 1); pane.add(viewer3, 1, 0); pane.add(viewer4, 1, 1); return pane; }
Example 15
Source File: SearchBar.java From Recaf with MIT License | 4 votes |
/** * @param text * Supplier of searchable text. */ public SearchBar(Supplier<String> text) { setAlignment(Pos.CENTER_LEFT); setHgap(7); ColumnConstraints column1 = new ColumnConstraints(); column1.setPercentWidth(75); ColumnConstraints column2 = new ColumnConstraints(); column2.setPercentWidth(25); getColumnConstraints().addAll(column1, column2); // TODO: Better search field: // - Options // - case sensitivity // - regex this.text = text; getStyleClass().add("context-menu"); txtSearch.getStyleClass().add("search-field"); txtSearch.setOnKeyPressed(e -> { // Check if we've updated the search query String searchText = e.getText(); if(!searchText.equals(lastSearchText)) { dirty = true; } lastSearchText = searchText; // Handle operations if(e.getCode().getName().equals(KeyCode.ESCAPE.getName())) { // Escape the search bar if(onEscape != null) onEscape.run(); } else if(e.getCode().getName().equals(KeyCode.ENTER.getName())) { // Empty check if (txtSearch.getText().isEmpty()) { results = null; return; } // Find next // - Run search if necessary if(dirty) { results = search(); dirty = false; } if(onSearch != null && results != null) onSearch.accept(results); } }); add(txtSearch, 0, 0); add(lblResults, 1, 0); }
Example 16
Source File: FXStockChart.java From Rails with GNU General Public License v2.0 | 3 votes |
/** * Creates a {@link ColumnConstraints} object with the given width factor. * The width factor defines, how much wider the column is compared to other columns. * A factor of 2 means, that the column is twice as wide as a column with the factor 1 * * @param factor The width factor * @return The created constraint */ private ColumnConstraints createColumn(int factor) { ColumnConstraints constraints = new ColumnConstraints(); constraints.setPercentWidth(100d / ((market.getNumberOfColumns() * 2) + 1) * factor); return constraints; }