Screen screen = Screen.getPrimary(); Rectangle2D bounds = screen.getVisualBounds(); //let the window use the left half screen: stage.setX(bounds.getMinX()); stage.setY(bounds.getMinY()); stage.setWidth(bounds.getWidth() / 2); stage.setHeight(bounds.getHeight()); VBox vBox = new VBox(); vBox.setStyle("-fx-background-color: blue;"); Rectangle rect = new Rectangle(); rect.setStyle("-fx-fill: red;"); vBox.getChildren().add(rect); //not necessary, because always max size (root element of the scene): //vBox.minWidthProperty().bind(stage.widthProperty()); //vBox.minHeightProperty().bind(stage.heightProperty()); rect.widthProperty().bind(vBox.widthProperty()); rect.heightProperty().bind(vBox.heightProperty().divide(3)); stage.setScene(new Scene(vBox)); stage.show();
static class InfiniteNumberItem extends TreeItem<String> { boolean expanded = false; public InfiniteNumberItem(String name) { super(name); } @Override public ObservableList<TreeItem<String>> getChildren() { if (!expanded) { for (int i = 0; i < 10; i++) { super.getChildren().add(new InfiniteNumberItem(""+i)); } expanded = true; } return super.getChildren(); } @Override public boolean isLeaf() { return false; } } void testTreeInfinite(VBox box) { TreeView<String> tree = new TreeView<String>(); tree.prefHeightProperty().bind(box.heightProperty()); tree.setRoot(new InfiniteNumberItem("3.")); box.getChildren().add(tree); }
void testLabelPlains3(VBox box) { Text first = new Text("first"); box.heightProperty().addListener(p -> { first.setScaleY(0.8*box.getHeight()/20); first.setTranslateY(box.getHeight()/2); }); box.widthProperty().addListener(p -> { first.setScaleX(0.8*box.getWidth()/30); first.setTranslateX(box.getWidth()/2); }); box.getChildren().addAll(first); }
box.heightProperty().addListener((ov, oldValue, newValue) -> { pane.setVvalue(pane.getVmax()); });
vbox.heightProperty().addListener(resizeListener);
@Override public void initialize() { followButton.setDisable(true); userBanner.fitWidthProperty().bind(userDetailsVBox.widthProperty()); userBanner.fitHeightProperty().bind(userDetailsVBox.heightProperty()); userBanner.setPreserveRatio(false); userBanner.setImage(ImageResources.BACKGROUND_DARK_1PX.getImage()); userProfilePictureImageView.setImage(ImageResources.GENERAL_USER_AVATAR_LIGHT.getImage()); final Rectangle profilePictureClip = Clipping.getSquareClip(290.0, 50.0); userProfilePictureImageView.setClip(profilePictureClip); if (targetUserProp.getValue() == null) { this.targetUserProp.addListener((o, prev, cur) -> displayTargetUser()); } else { displayTargetUser(); } }
/** * {@inheritDoc} */ @Override public void initialise() { final VBox container = new VBox(createMiniature(), createLabel()); container.getStyleClass().add("iconListElement"); container.widthProperty().addListener((observable, oldValue, newValue) -> container .setClip(new Rectangle(container.getWidth(), container.getHeight()))); container.heightProperty().addListener((observable, oldValue, newValue) -> container .setClip(new Rectangle(container.getWidth(), container.getHeight()))); // update the selected pseudo class according to the selected state of the component getControl().selectedProperty().addListener((Observable invalidation) -> container .pseudoClassStateChanged(SELECTED_PSEUDO_CLASS, getControl().isSelected())); // adopt the selected state during initialisation container.pseudoClassStateChanged(SELECTED_PSEUDO_CLASS, getControl().isSelected()); getChildren().addAll(container); }