javafx.scene.layout.Region Java Examples
The following examples show how to use
javafx.scene.layout.Region.
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: FxmlStage.java From MyBox with Apache License 2.0 | 6 votes |
public static void alertInformation(Stage myStage, String information) { try { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle(myStage.getTitle()); alert.setHeaderText(null); alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE); alert.getDialogPane().setContent(new Label(information)); // alert.setContentText(information); Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); stage.setAlwaysOnTop(true); stage.toFront(); alert.showAndWait(); } catch (Exception e) { logger.error(e.toString()); } }
Example #2
Source File: StaticProgressIndicatorSkin.java From bisq with GNU Affero General Public License v3.0 | 6 votes |
private void rebuild() { // update indeterminate indicator final int segments = skin.indeterminateSegmentCount.get(); opacities.clear(); pathsG.getChildren().clear(); final double step = 0.8 / (segments - 1); for (int i = 0; i < segments; i++) { Region region = new Region(); region.setScaleShape(false); region.setCenterShape(false); region.getStyleClass().addAll("segment", "segment" + i); if (fillOverride instanceof Color) { Color c = (Color) fillOverride; region.setStyle("-fx-background-color: rgba(" + ((int) (255 * c.getRed())) + "," + "" + ((int) (255 * c.getGreen())) + "," + ((int) (255 * c.getBlue())) + "," + "" + c.getOpacity() + ");"); } else { region.setStyle(null); } double opacity = Math.min(1, i * step); opacities.add(opacity); region.setOpacity(opacity); pathsG.getChildren().add(region); } }
Example #3
Source File: Demo.java From tilesfx with Apache License 2.0 | 6 votes |
private HBox getCountryItem(final Flag flag, final String text, final String data) { ImageView imageView = new ImageView(flag.getImage(22)); HBox.setHgrow(imageView, Priority.NEVER); Label name = new Label(text); name.setTextFill(Tile.FOREGROUND); name.setAlignment(Pos.CENTER_LEFT); HBox.setHgrow(name, Priority.NEVER); Region spacer = new Region(); spacer.setPrefSize(5, 5); HBox.setHgrow(spacer, Priority.ALWAYS); Label views = new Label(data); views.setTextFill(Tile.FOREGROUND); views.setAlignment(Pos.CENTER_RIGHT); HBox.setHgrow(views, Priority.NEVER); HBox hBox = new HBox(5, imageView, name, spacer, views); hBox.setAlignment(Pos.CENTER_LEFT); hBox.setFillHeight(true); return hBox; }
Example #4
Source File: NCCFactory.java From FXGLGames with MIT License | 6 votes |
@Spawns("cardPlaceholder") public Entity newPlaceholder(SpawnData data) { var bg = new Region(); bg.setPrefSize(CARD_WIDTH, CARD_HEIGHT); bg.setStyle( "-fx-background-color: gold;" + "-fx-border-color: black;" + "-fx-border-width: 5;" + "-fx-border-style: segments(10, 15, 15, 15) line-cap round;" ); var text = getUIFactory().newText(data.get("isPlayer") ? "+" : "?", Color.WHITE, 76); text.setStroke(Color.BLACK); text.setStrokeWidth(2); return entityBuilder() .from(data) .view(new StackPane(bg, text)) .build(); }
Example #5
Source File: JFXTable.java From tuxguitar with GNU Lesser General Public License v2.1 | 6 votes |
public JFXTable(JFXContainer<? extends Region> parent, boolean headerVisible, boolean checkable) { super(new TableView<UITableItem<T>>(), parent); this.selectionListener = new JFXSelectionListenerChangeManagerAsync<UITableItem<T>>(this); this.checkSelectionListener = new JFXCheckTableSelectionListenerManager<T>(this); this.cellFactory = new JFXTableCellFactory<T>(this, checkable); this.cellValueFactory = new JFXTableCellValueFactory<T>(); this.getControl().setEditable(true); this.getControl().getSelectionModel().setSelectionMode(SelectionMode.SINGLE); this.getControl().widthProperty().addListener(new ChangeListener<Number>() { public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { JFXTable.this.fillAvailableWidth(); } }); }
Example #6
Source File: Workbench.java From WorkbenchFX with Apache License 2.0 | 6 votes |
/** * Shows the {@code overlay} on top of the view, with a {@link GlassPane} in the background. * * @param overlay to be shown * @param blocking If false (non-blocking), clicking outside of the {@code overlay} will cause it * to get hidden, together with its {@link GlassPane}. If true (blocking), * clicking outside of the {@code overlay} will not do anything. The {@code * overlay} itself must call {@link Workbench#hideOverlay(Region)} to hide it. * @return true if the overlay is not being shown already */ public final boolean showOverlay(Region overlay, boolean blocking) { LOGGER.trace("showOverlay"); if (!overlays.containsKey(overlay)) { overlays.put(overlay, new WorkbenchOverlay(overlay, new GlassPane())); } // To prevent showing the same overlay twice if (blockingOverlaysShown.contains(overlay) || nonBlockingOverlaysShown.contains(overlay)) { return false; } if (blocking) { LOGGER.trace("showOverlay - blocking"); return blockingOverlaysShown.add(overlay); } else { LOGGER.trace("showOverlay - non-blocking"); return nonBlockingOverlaysShown.add(overlay); } }
Example #7
Source File: Builders.java From PDF4Teachers with Apache License 2.0 | 6 votes |
public static void setHBoxPosition(Region element, double width, double height, Insets margin){ if(width == -1){ HBox.setHgrow(element, Priority.ALWAYS); element.setMaxWidth(Double.MAX_VALUE); }else if(width != 0){ element.setPrefWidth(width); element.minWidthProperty().bind(new SimpleDoubleProperty(width)); } if(height == -1){ VBox.setVgrow(element, Priority.ALWAYS); }else if(height != 0){ element.setPrefHeight(height); element.minHeightProperty().bind(new SimpleDoubleProperty(height)); } HBox.setMargin(element, margin); }
Example #8
Source File: BaseController.java From MyBox with Apache License 2.0 | 6 votes |
public boolean clearSettings() { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle(getBaseTitle()); alert.setContentText(AppVariables.message("SureClear")); alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE); ButtonType buttonSure = new ButtonType(AppVariables.message("Sure")); ButtonType buttonCancel = new ButtonType(AppVariables.message("Cancel")); alert.getButtonTypes().setAll(buttonSure, buttonCancel); Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); stage.setAlwaysOnTop(true); stage.toFront(); Optional<ButtonType> result = alert.showAndWait(); if (result.get() != buttonSure) { return false; } DerbyBase.clearData(); cleanAppPath(); AppVariables.initAppVaribles(); return true; }
Example #9
Source File: MarathonCheckListStage.java From marathonv5 with Apache License 2.0 | 6 votes |
private void initCheckList() { ToolBar toolBar = new ToolBar(); toolBar.getItems().add(new Text("Check Lists")); toolBar.setMinWidth(Region.USE_PREF_SIZE); leftPane.setTop(toolBar); checkListElements = checkListInfo.getCheckListElements(); checkListView = new ListView<CheckListForm.CheckListElement>(checkListElements); checkListView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> { CheckListElement selectedItem = checkListView.getSelectionModel().getSelectedItem(); if (selectedItem == null) { doneButton.setDisable(true); return; } Node checkListForm = getChecklistFormNode(selectedItem, Mode.DISPLAY); if (checkListForm == null) { doneButton.setDisable(true); return; } doneButton.setDisable(false); ScrollPane sp = new ScrollPane(checkListForm); sp.setFitToWidth(true); sp.setPadding(new Insets(0, 0, 0, 10)); rightPane.setCenter(sp); }); leftPane.setCenter(checkListView); }
Example #10
Source File: ResizePolicyTests.java From gef with Eclipse Public License 2.0 | 6 votes |
@Test public void test_minimumSize_Region() { /* * This test ensures that Bugzilla #512620 is not re-introduced by a * later change. */ // check resize policy is reset assertEquals(0d, resizePolicy.getDeltaWidth(), 0.01); assertEquals(0d, resizePolicy.getDeltaHeight(), 0.01); // set region's min-size to USE_COMPUTED_SIZE Region region = (Region) resizePolicy.getHost().getVisual(); region.setMinSize(Region.USE_COMPUTED_SIZE, Region.USE_COMPUTED_SIZE); assertEquals(Region.USE_COMPUTED_SIZE, region.getMinWidth(), 0.01); assertEquals(Region.USE_COMPUTED_SIZE, region.getMinHeight(), 0.01); // resize below minimum size using ResizePolicy resizePolicy.resize(region.minWidth(-1) - 5, region.minHeight(-1) - 5); // ensure minimum size is respected assertEquals(region.minWidth(-1), resizePolicy.getDeltaWidth(), 0.01); assertEquals(region.minHeight(-1), resizePolicy.getDeltaHeight(), 0.01); }
Example #11
Source File: CellGestures.java From fxgraph with Do What The F*ck You Want To Public License | 6 votes |
@Override public Node apply(Region region, Wrapper<Point2D> mouseLocation) { final DoubleProperty xProperty = region.layoutXProperty(); final DoubleProperty yProperty = region.layoutYProperty(); final ReadOnlyDoubleProperty widthProperty = region.prefWidthProperty(); final ReadOnlyDoubleProperty heightProperty = region.prefHeightProperty(); final DoubleBinding halfHeightProperty = heightProperty.divide(2); final Rectangle resizeHandleE = new Rectangle(handleRadius, handleRadius, Color.BLACK); resizeHandleE.xProperty().bind(xProperty.add(widthProperty).subtract(handleRadius / 2)); resizeHandleE.yProperty().bind(yProperty.add(halfHeightProperty).subtract(handleRadius / 2)); setUpDragging(resizeHandleE, mouseLocation, Cursor.E_RESIZE); resizeHandleE.setOnMouseDragged(event -> { if(mouseLocation.value != null) { dragEast(event, mouseLocation, region, handleRadius); mouseLocation.value = new Point2D(event.getSceneX(), event.getSceneY()); } }); return resizeHandleE; }
Example #12
Source File: JFXTextAreaSkinBisqStyle.java From bisq with GNU Affero General Public License v3.0 | 6 votes |
@Override protected void layoutChildren(final double x, final double y, final double w, final double h) { super.layoutChildren(x, y, w, h); final double height = getSkinnable().getHeight(); final double width = getSkinnable().getWidth(); linesWrapper.layoutLines(x - 2, y - 2, width, h, height, promptText == null ? 0 : promptText.getLayoutBounds().getHeight() + 3); errorContainer.layoutPane(x, height + linesWrapper.focusedLine.getHeight(), width, h); linesWrapper.updateLabelFloatLayout(); if (invalid) { invalid = false; // set the default background of text area viewport to white Region viewPort = (Region) scrollPane.getChildrenUnmodifiable().get(0); viewPort.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY))); // reapply css of scroll pane in case set by the user viewPort.applyCss(); errorContainer.invalid(w); // focus linesWrapper.invalid(); } }
Example #13
Source File: FxmlStage.java From MyBox with Apache License 2.0 | 6 votes |
public static void alertError(Stage myStage, String information) { try { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle(myStage.getTitle()); alert.setHeaderText(null); alert.setContentText(information); alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE); // https://stackoverflow.com/questions/38799220/javafx-how-to-bring-dialog-alert-to-the-front-of-the-screen?r=SearchResults Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); stage.setAlwaysOnTop(true); stage.toFront(); alert.showAndWait(); } catch (Exception e) { logger.error(e.toString()); } }
Example #14
Source File: JFXDialog.java From JFoenix with Apache License 2.0 | 6 votes |
private void initialize() { this.setVisible(false); this.getStyleClass().add(DEFAULT_STYLE_CLASS); this.transitionType.addListener((o, oldVal, newVal) -> { animation = getShowAnimation(transitionType.get()); }); contentHolder = new StackPane(); contentHolder.setBackground(new Background(new BackgroundFill(Color.WHITE, new CornerRadii(2), null))); JFXDepthManager.setDepth(contentHolder, 4); contentHolder.setPickOnBounds(false); // ensure stackpane is never resized beyond it's preferred size contentHolder.setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE); this.getChildren().add(contentHolder); this.getStyleClass().add("jfx-dialog-overlay-pane"); StackPane.setAlignment(contentHolder, Pos.CENTER); this.setBackground(new Background(new BackgroundFill(Color.rgb(0, 0, 0, 0.1), null, null))); // close the dialog if clicked on the overlay pane if (overlayClose.get()) { this.addEventHandler(MouseEvent.MOUSE_PRESSED, closeHandler); } // prevent propagating the events to overlay pane contentHolder.addEventHandler(MouseEvent.ANY, e -> e.consume()); }
Example #15
Source File: RadioButtonDrivenTextFieldsPane.java From pdfsam with GNU Affero General Public License v3.0 | 6 votes |
public void addRow(RadioButton radio, Region field, Text helpIcon) { requireNotNullArg(radio, "Cannot add a null radio"); requireNotNullArg(field, "Cannot add a null field"); GridPane.setValignment(radio, VPos.BOTTOM); GridPane.setValignment(field, VPos.BOTTOM); GridPane.setHalignment(radio, HPos.LEFT); GridPane.setHalignment(field, HPos.LEFT); GridPane.setFillWidth(field, true); field.setPrefWidth(300); field.setDisable(true); radio.selectedProperty().addListener((o, oldVal, newVal) -> { field.setDisable(!newVal); if (newVal) { field.requestFocus(); } }); radio.setToggleGroup(group); add(radio, 0, rows); add(field, 1, rows); if (nonNull(helpIcon)) { add(helpIcon, 2, rows); } rows++; }
Example #16
Source File: Led.java From JFX8CustomControls with Apache License 2.0 | 6 votes |
private void initGraphics() { frame = new Region(); frame.getStyleClass().setAll("frame"); frame.setOpacity(isFrameVisible() ? 1 : 0); led = new Region(); led.getStyleClass().setAll("main"); led.setStyle("-led-color: " + (getLedColor()).toString().replace("0x", "#") + ";"); innerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), 8, 0d, 0d, 0d); glow = new DropShadow(BlurType.TWO_PASS_BOX, getLedColor(), 20, 0d, 0d, 0d); glow.setInput(innerShadow); highlight = new Region(); highlight.getStyleClass().setAll("highlight"); // Add all nodes getChildren().addAll(frame, led, highlight); }
Example #17
Source File: EpidemicReportsImportController.java From MyBox with Apache License 2.0 | 6 votes |
@Override public void afterSuccessful() { if (statisticCheck == null) { return; } if (statisticCheck.isSelected()) { startStatistic(); } else { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle("MyBox"); alert.setContentText(message("EpidemicReportStatistic")); alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE); ButtonType buttonOK = new ButtonType(AppVariables.message("OK")); ButtonType buttonCancel = new ButtonType(AppVariables.message("Cancel")); alert.getButtonTypes().setAll(buttonOK, buttonCancel); Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); stage.setAlwaysOnTop(true); stage.toFront(); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == buttonOK) { startStatistic(); } } }
Example #18
Source File: NCCFactory.java From FXGLGames with MIT License | 6 votes |
@Spawns("cardPlaceholder") public Entity newPlaceholder(SpawnData data) { var bg = new Region(); bg.setPrefSize(CARD_WIDTH, CARD_HEIGHT); bg.setStyle( "-fx-background-color: gold;" + "-fx-border-color: black;" + "-fx-border-width: 5;" + "-fx-border-style: segments(10, 15, 15, 15) line-cap round;" ); var text = getUIFactory().newText(data.get("isPlayer") ? "+" : "?", Color.WHITE, 76); text.setStroke(Color.BLACK); text.setStrokeWidth(2); return entityBuilder() .from(data) .view(new StackPane(bg, text)) .build(); }
Example #19
Source File: StructuredListCellSkin.java From dolphin-platform with Apache License 2.0 | 6 votes |
protected StructuredListCellSkin(StructuredListCell control) { super(control); getSkinnable().leftContentProperty().addListener(e -> updateContent()); getSkinnable().centerContentProperty().addListener(e -> updateContent()); getSkinnable().rightContentProperty().addListener(e -> updateContent()); updateContent(); leftContentAlignment = CssHelper.createProperty(StyleableProperties.LEFT_CONTENT_ALIGNMENT, this); rightContentAlignment = CssHelper.createProperty(StyleableProperties.RIGHT_CONTENT_ALIGNMENT, this); centerContentAlignment = CssHelper.createProperty(StyleableProperties.CENTER_CONTENT_ALIGNMENT, this); spacing = CssHelper.createProperty(StyleableProperties.SPACING, this); componentForPrefHeight = CssHelper.createProperty(StyleableProperties.CONTENT_FOR_PREF_HEIGHT, this); getSkinnable().itemProperty().addListener(e -> { updateVisibility(); }); getSkinnable().setMaxHeight(Region.USE_PREF_SIZE); getSkinnable().setMinHeight(Region.USE_PREF_SIZE); }
Example #20
Source File: JFXAutoCompletePopup.java From JFoenix with Apache License 2.0 | 5 votes |
public void show(Node node){ if(!isShowing()){ if(node.getScene() == null || node.getScene().getWindow() == null) throw new IllegalStateException("Can not show popup. The node must be attached to a scene/window."); Window parent = node.getScene().getWindow(); this.show(parent, parent.getX() + node.localToScene(0, 0).getX() + node.getScene().getX(), parent.getY() + node.localToScene(0, 0).getY() + node.getScene().getY() + ((Region)node).getHeight()); ((JFXAutoCompletePopupSkin<T>)getSkin()).animate(); } }
Example #21
Source File: JFXScrollBarPanel.java From tuxguitar with GNU Lesser General Public License v2.1 | 5 votes |
public JFXScrollBarPanel(JFXContainer<? extends Region> parent, boolean vScroll, boolean hScroll, boolean bordered) { super(parent, bordered); if( vScroll ) { this.vScrollBar = this.createScrollBar(Orientation.VERTICAL); } if( hScroll ) { this.hScrollBar = this.createScrollBar(Orientation.HORIZONTAL); } this.getControl().setOnScroll(new JFXScrollBarPanelScrollListener(this)); }
Example #22
Source File: DetailsPanelSkin.java From phoenicis with GNU Lesser General Public License v3.0 | 5 votes |
/** * Creates the header for the details panel. * The header contains an optional title and a close button * * @return The header */ private HBox createHeader() { final Label titleLabel = new Label(); titleLabel.getStyleClass().add("descriptionTitle"); titleLabel.textProperty().bind(getControl().titleProperty()); final Button closeButton = new Button(); closeButton.getStyleClass().add("closeIcon"); closeButton.setOnAction(event -> Optional.ofNullable(getControl().getOnClose()).ifPresent(Runnable::run)); final Region filler = new Region(); HBox.setHgrow(filler, Priority.ALWAYS); return new HBox(titleLabel, filler, closeButton); }
Example #23
Source File: FxmlControl.java From MyBox with Apache License 2.0 | 5 votes |
public static void moveYCenter(Region pNnode, Node node) { if (node == null || pNnode == null) { return; } double yOffset = pNnode.getHeight() - node.getBoundsInLocal().getHeight(); if (yOffset > 0) { node.setLayoutY(pNnode.getLayoutY() + yOffset / 2); } }
Example #24
Source File: DropOp.java From FxDock with Apache License 2.0 | 5 votes |
public void addRect(Node ref, double x, double y, double w, double h) { BoundingBox screenr = new BoundingBox(x, y, w, h); Bounds b = ref.localToScreen(screenr); b = target.screenToLocal(b); Region r = new Region(); r.relocate(b.getMinX(), b.getMinY()); r.resize(b.getWidth(), b.getHeight()); r.setBackground(FX.background(Color.color(0, 0, 0, 0.3))); add(r); }
Example #25
Source File: ThermometerRepresentation.java From phoebus with Eclipse Public License 1.0 | 5 votes |
@Override public Region createJFXNode() throws Exception { final Thermo thermo = new Thermo(); // This code manages layout, // because otherwise for example border changes would trigger // expensive Node.notifyParentOfBoundsChange() recursing up the scene graph thermo.setManaged(false); return thermo; }
Example #26
Source File: UploadPane.java From pattypan with MIT License | 5 votes |
private void setContent() { addElement("upload-intro", 40); stopButton.setDisable(true); addElementRow( new Node[]{new Region(), uploadButton, stopButton, new Region()}, new Priority[]{Priority.ALWAYS, Priority.NEVER, Priority.NEVER, Priority.ALWAYS} ); addElement(infoContainerScroll); addElement(statusLabel); nextButton.setVisible(false); }
Example #27
Source File: StepRepresentationSpin.java From phoenicis with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void drawStepContent() { super.drawStepContent(); Region spacerAbove = new Region(); VBox.setVgrow(spacerAbove, Priority.ALWAYS); this.addToContentPane(spacerAbove); ProgressIndicator progressIndicator = new ProgressIndicator(); this.addToContentPane(progressIndicator); Region spacerBelow = new Region(); VBox.setVgrow(spacerBelow, Priority.ALWAYS); this.addToContentPane(spacerBelow); }
Example #28
Source File: AssetEditorDialog.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
@Override @FxThread protected @NotNull Region buildFirstPart(@NotNull final HBox container) { resourceTree = new ResourceTree(this::processOpen, false); resourceTree.getSelectionModel() .selectedItemProperty() .addListener((observable, oldValue, newValue) -> processSelected(newValue)); return resourceTree; }
Example #29
Source File: VPane.java From FxDock with Apache License 2.0 | 5 votes |
/** adds an empty region with the FILL constraint */ public void fill() { Region n = new Region(); massage(n); getChildren().add(n); FX.setProperty(n, KEY_CONSTRAINT, FILL); }
Example #30
Source File: GraphEditorMinimap.java From graph-editor with Eclipse Public License 1.0 | 5 votes |
/** * Binds the aspect ratio of the minimap to the aspect ratio of the content that the minimap is representing. */ private void bindAspectRatioToContent(final Region content) { contentRatio = content.heightProperty().divide(content.widthProperty()); widthBeforePadding = widthProperty().subtract(2 * MINIMAP_PADDING); heightBeforePadding = widthBeforePadding.multiply(contentRatio); // This effectively rounds the height down to an integer. final FloorBinding flooredHeight = new FloorBinding(heightBeforePadding); minHeightProperty().bind(flooredHeight.add(2 * MINIMAP_PADDING)); prefHeightProperty().bind(flooredHeight.add(2 * MINIMAP_PADDING)); maxHeightProperty().bind(flooredHeight.add(2 * MINIMAP_PADDING)); }