@Override public void invalidated(Observable ignored) { if (Double.isNaN(dialog.getWidth()) || Double.isNaN(dialog.getHeight())) { return; } dialog.widthProperty().removeListener(positionAdjuster); dialog.heightProperty().removeListener(positionAdjuster); fixPosition(); } };
@Override public void start(Stage stage) throws Exception { BorderPane pane = new BorderPane(); ImageView img = new ImageView("http://..."); img.fitWidthProperty().bind(stage.widthProperty()); pane.setCenter(img); Scene scene = new Scene(pane); stage.setScene(scene); stage.show(); }
public void show() { dialog.setOpacity(0); // pickerDecorator.setOpacity(0); if (dialog.getOwner() != null) { dialog.widthProperty().addListener(positionAdjuster); dialog.heightProperty().addListener(positionAdjuster); positionAdjuster.invalidated(null); } if (dialog.getScene() == null) { dialog.setScene(customScene); } curvedColorPicker.preAnimate(); dialog.show(); if (initOnce) { initRun.run(); initOnce = false; } Timeline timeline = new Timeline(new KeyFrame(Duration.millis(120), new KeyValue(dialog.opacityProperty(), 1, Interpolator.EASE_BOTH))); timeline.setOnFinished((finish) -> curvedColorPicker.animate()); timeline.play(); }
NumberBinding currentWidthPlusTen = primaryStage.widthProperty() .add(10);
/** * add a size listener for the given stage * * @param stage */ public void addSizeListener(Stage stage) { this.addSizeListener(stage.widthProperty(), stage.heightProperty()); }
@Override public void invalidated(Observable ignored) { if (Double.isNaN(dialog.getWidth()) || Double.isNaN(dialog.getHeight())) { return; } dialog.widthProperty().removeListener(positionAdjuster); dialog.heightProperty().removeListener(positionAdjuster); fixPosition(); } };
@Override public void start(Stage stage) { ProgressBar pb = new ProgressBar(-1); stage.setScene(new Scene(new VBox(pb), 300, 250)); stage.show(); //screwed up on first showing from this bind pb.prefWidthProperty().bind(stage.widthProperty().divide(2)); //gets fixed when resized pb.prefWidthProperty().addListener((obs,ov,nv)->{ pb.setProgress(0); pb.setProgress(-1); }); }
primaryStage.widthProperty().addListener(listener); primaryStage.heightProperty().addListener(listener);
import javafx.application.Application; import javafx.collections.ObservableList; import javafx.scene.Scene; import javafx.scene.control.TableView; import javafx.stage.Stage; public class MCVE extends Application { @Override public void start(Stage stage) { TableView<ObservableList<String>> table = new TableView<ObservableList<String>>(); // We bind the prefHeight- and prefWidthProperty to the height and width of the stage. table.prefHeightProperty().bind(stage.heightProperty()); table.prefWidthProperty().bind(stage.widthProperty()); stage.setScene(new Scene(table, 400, 400)); stage.show(); } public static void main(String[] args) { launch(); } }
}); primaryStage.widthProperty().addListener((obs, oldWidth, newWidth) -> { if (mouseLocation.x < primaryStage.getWidth() / 2) { System.out.println("Resized from left");
primaryStage.widthProperty().addListener((obs, oldWidth, newWidth) -> { if (primaryStage.getX() == windowLeftEdge.value) { System.out.println("Resized from right");
primaryStage.widthProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> arg0, Number arg1, Number arg2) {
/** * setup the xyTabPane and it's behavior */ public void setupXyTabPane() { // add the xyTabPane getRoot().getChildren().add(xyTabPane); // make sure it shrinks and grows with the scene NumberBinding heightAdjust = getStage().heightProperty() .add(menuBar.heightProperty()); xyTabPane.getvTabPane().prefHeightProperty() .bind(heightAdjust.add(-xyTabPane.getTabSize())); xyTabPane.getvTabPane().prefWidthProperty() .bind(getStage().widthProperty().add(0)); // -xyTabPane.getTabSize() }
menuBar.prefWidthProperty().bind(primaryStage.widthProperty()); menuBar.getMenus().add(menu);
blockingRect.widthProperty().bind(primaryStage.widthProperty()); blockingRect.heightProperty().bind(primaryStage.heightProperty()); blockingRect.setFill(Color.LIGHTBLUE);
imageView.fitWidthProperty().bind(stage.widthProperty()); imageView.fitHeightProperty().bind(stage.heightProperty()); imageView.setPreserveRatio(true);
public void show() { dialog.setOpacity(0); // pickerDecorator.setOpacity(0); if (dialog.getOwner() != null) { dialog.widthProperty().addListener(positionAdjuster); dialog.heightProperty().addListener(positionAdjuster); positionAdjuster.invalidated(null); } if (dialog.getScene() == null) { dialog.setScene(customScene); } curvedColorPicker.preAnimate(); dialog.show(); if (initOnce) { initRun.run(); initOnce = false; } Timeline timeline = new Timeline(new KeyFrame(Duration.millis(120), new KeyValue(dialog.opacityProperty(), 1, Interpolator.EASE_BOTH))); timeline.setOnFinished((finish) -> curvedColorPicker.animate()); timeline.play(); }
x.bind(ViewStructure.primaryStage().xProperty().add(ViewStructure.primaryStage().widthProperty().subtract(dialogStage.widthProperty()).divide(2)));
doLayout(); final IResponsiveAreaSize areasSize = responsiveMatrix.getSizeOf(ViewStructure.primaryStage().widthProperty().get()); applyContentMatrix(areasSize);
doLayout(); final IResponsiveAreaSize areasSize = responsiveMatrix.getSizeOf(ViewStructure.primaryStage().widthProperty().get()); applyContentMatrix(areasSize);