Java Code Examples for javafx.scene.layout.Region

The following examples show how to use javafx.scene.layout.Region. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: dolphin-platform   Source File: StructuredListCellSkin.java    License: Apache License 2.0 6 votes vote down vote up
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 2
Source Project: FXGLGames   Source File: NCCFactory.java    License: MIT License 6 votes vote down vote up
@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 3
Source Project: tilesfx   Source File: Demo.java    License: Apache License 2.0 6 votes vote down vote up
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 Project: marathonv5   Source File: MarathonCheckListStage.java    License: Apache License 2.0 6 votes vote down vote up
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 5
Source Project: gef   Source File: ResizePolicyTests.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@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 6
Source Project: FXGLGames   Source File: NCCFactory.java    License: MIT License 6 votes vote down vote up
@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 7
@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 8
Source Project: JFoenix   Source File: JFXDialog.java    License: Apache License 2.0 6 votes vote down vote up
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 9
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 10
Source Project: MyBox   Source File: EpidemicReportsImportController.java    License: Apache License 2.0 6 votes vote down vote up
@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 11
Source Project: MyBox   Source File: FxmlStage.java    License: Apache License 2.0 6 votes vote down vote up
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 12
Source Project: JFX8CustomControls   Source File: Led.java    License: Apache License 2.0 6 votes vote down vote up
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 13
Source Project: MyBox   Source File: FxmlStage.java    License: Apache License 2.0 6 votes vote down vote up
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
@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 15
Source Project: MyBox   Source File: BaseController.java    License: Apache License 2.0 6 votes vote down vote up
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 16
Source Project: PDF4Teachers   Source File: Builders.java    License: Apache License 2.0 6 votes vote down vote up
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 17
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 18
Source Project: tuxguitar   Source File: JFXTable.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
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 19
Source Project: WorkbenchFX   Source File: Workbench.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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 20
Source Project: FxDock   Source File: VPane.java    License: Apache License 2.0 5 votes vote down vote up
/** 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 21
Source Project: gef   Source File: IResizableContentPart.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Resizes the visual of this {@link IResizableContentPart} to the given
 * size.
 *
 * @param totalSize
 *            The new size for this {@link IResizableContentPart}'s visual.
 */
public default void setVisualSize(Dimension totalSize) {
	if (getVisual() instanceof Region) {
		// A Region should not be resized directly. Instead, its size
		// constraints should be adjusted so that it will be resized to the
		// desired size during the next layout pass.
		((Region) getVisual()).setPrefSize(totalSize.width,
				totalSize.height);
		((Region) getVisual()).autosize();
	} else {
		// resize manually
		getVisual().resize(totalSize.width, totalSize.height);
	}
}
 
Example 22
Source Project: marathonv5   Source File: AceEditorPreferencesStage.java    License: Apache License 2.0 5 votes vote down vote up
private void initComponents() {
    okButton.setOnAction((e) -> onOk());
    cancelButton.setOnAction((e) -> onCancel());
    defaultsButton.setOnAction((e) -> onDefault());

    buttonBar.setButtonMinWidth(Region.USE_PREF_SIZE);
    buttonBar.getButtons().addAll(okButton, cancelButton, defaultsButton);
}
 
Example 23
private static void dragSouth(MouseEvent event, Wrapper<Point2D> mouseLocation, Region region, double handleRadius) {
	final double deltaY = event.getSceneY() - mouseLocation.value.getY();
	final double newMaxY = region.getLayoutY() + region.getHeight() + deltaY;
	if(newMaxY >= region.getLayoutY() && newMaxY <= region.getParent().getBoundsInLocal().getHeight() - handleRadius) {
		region.setPrefHeight(region.getPrefHeight() + deltaY);
	}
}
 
Example 24
Source Project: DevToolBox   Source File: Loading.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
public void startMainApp(Stage ms) {
    try {
        long time = System.currentTimeMillis();
        Stage stage = new Stage();
        stage.setTitle(Undecorator.LOC.getString("AppName") + " " + Undecorator.LOC.getString("Version") + " 版本号:" + Undecorator.LOC.getString("VersionCode"));
        FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/main.fxml"));
        Region root = (Region) fxmlLoader.load();
        final UndecoratorScene undecoratorScene = new UndecoratorScene(stage, root);
        stage.setOnCloseRequest((WindowEvent we) -> {
            we.consume();
            undecoratorScene.setFadeOutTransition();
        });
        undecoratorScene.getStylesheets().add("/styles/main.css");
        stage.setScene(undecoratorScene);
        stage.toFront();
        stage.getIcons().add(new Image(getClass().getResourceAsStream("/skin/icon.png")));
        stage.setOnShown((event) -> {
            new Timer().schedule(new TimerTask() {
                @Override
                public void run() {
                    Platform.runLater(() -> {
                        ms.close();
                    });
                }
            }, 1000);
        });
        stage.show();
        ApplicationStageManager.putStageAndController(ApplicationStageManager.StateAndController.MAIN, stage, fxmlLoader.getController());
        LOGGER.info("主页面加载耗时:" + (System.currentTimeMillis() - time) + "毫秒");
    } catch (IOException ex) {
        LOGGER.error("启动主程序异常", ex);
    }
}
 
Example 25
Source Project: HubTurbo   Source File: LoginDialog.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Configures the central grid pane before it's used.
 */
private static void setupGridPane(GridPane grid) {
    grid.setAlignment(Pos.CENTER);
    grid.setHgap(7);
    grid.setVgap(10);
    grid.setPadding(new Insets(25));
    grid.setPrefSize(390, 100);
    grid.setMaxSize(Region.USE_COMPUTED_SIZE, Region.USE_COMPUTED_SIZE);
    applyColumnConstraints(grid, 20, 16, 33, 2, 29);
}
 
Example 26
/**
 * UndecoratorScene constructor
 *
 * @param stage The main stage
 * @param stageStyle could be StageStyle.UTILITY or StageStyle.TRANSPARENT
 * @param root your UI to be displayed in the Stage
 * @param stageDecorationFxml Your own Stage decoration or null to use the
 * built-in one
 */
public UndecoratorScene(Stage stage, StageStyle stageStyle, Region root, String stageDecorationFxml) {
    super(root);
    myRoot = root;
    /*
     * Fxml
     */
    if (stageDecorationFxml == null) {
        if (stageStyle == StageStyle.UTILITY) {
            stageDecorationFxml = STAGEDECORATION_UTILITY;
        } else {
            stageDecorationFxml = STAGEDECORATION;
        }
    }
    undecorator = new Undecorator(stage, root, stageDecorationFxml, stageStyle);
    super.setRoot(undecorator);

    // Customize it by CSS if needed:
    if (stageStyle == StageStyle.UTILITY) {
        undecorator.getStylesheets().add(STYLESHEET_UTILITY);
    } else {
        undecorator.getStylesheets().add(STYLESHEET);
    }

    // Transparent scene and stage
    if (stage.getStyle() != StageStyle.TRANSPARENT) {
        stage.initStyle(StageStyle.TRANSPARENT);
    }
    super.setFill(Color.TRANSPARENT);

    // Default Accelerators
    undecorator.installAccelerators(this);

    // Forward pref and max size to main stage
    stage.setMinWidth(undecorator.getMinWidth());
    stage.setMinHeight(undecorator.getMinHeight());
    stage.setWidth(undecorator.getPrefWidth());
    stage.setHeight(undecorator.getPrefHeight());
}
 
Example 27
Source Project: tuxguitar   Source File: JFXKnob.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
public JFXKnob(JFXContainer<? extends Region> parent) {
	super(parent, false);
	
	this.maximum = DEFAULT_MAXIMUM;
	this.minimum = DEFAULT_MINIMUM;
	this.increment = DEFAULT_INCREMENT;
	this.selectionHandler = new UISelectionListenerManager();
	this.addPaintListener(this);
	this.addMouseUpListener(this);
	this.addMouseDragListener(this);
	this.addMouseWheelListener(this);
}
 
Example 28
Source Project: SpaceFX   Source File: SpaceFXView.java    License: Apache License 2.0 5 votes vote down vote up
private HBox createHallOfFameEntry(final Player player) {
    Label playerName  = new Label(player.name);
    playerName.setTextFill(SPACEFX_COLOR);

    Region spacer = new Region();
    HBox.setHgrow(spacer, Priority.ALWAYS);

    Label playerScore = new Label(Long.toString(player.score));
    playerScore.setTextFill(SPACEFX_COLOR);
    playerScore.setAlignment(Pos.CENTER_RIGHT);

    HBox entry = new HBox(20, playerName, spacer, playerScore);
    entry.setPrefWidth(WIDTH);
    return entry;
}
 
Example 29
Source Project: JFoenix   Source File: JFXDialog.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * set the content of the dialog
 *
 * @param content
 */
public void setContent(Region content) {
    if (content != null) {
        this.content = content;
        this.content.setPickOnBounds(false);
        contentHolder.getChildren().setAll(content);
    }
}
 
Example 30
Source Project: FxDock   Source File: HPane.java    License: Apache License 2.0 5 votes vote down vote up
protected void massage(Node n)
{
	// once in an HPane, surrender your limitations!
	if(n instanceof Region)
	{
		Region r = (Region)n;
		r.setMaxHeight(Double.MAX_VALUE);
		r.setMaxWidth(Double.MAX_VALUE);
	}
}