UndecoratorBis
UndecoratorBis copied to clipboard
UndecoratorScene: sizeToScene with no effect!
Hallo, I'm new in javafx and UndecoratorBis.
In my example has sizeToScene no effect. Using act UndecoratorBis and java version "1.8.0_40" (build 1.8.0_40-b26).
Can you help me? Example:
import javafx.application.Application; import javafx.application.Platform; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.control.Control; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.control.ScrollPane; import javafx.scene.layout.HBox; import javafx.scene.layout.BorderPane; import javafx.scene.layout.VBox; import javafx.stage.Stage; import javafx.stage.StageStyle; import javafx.application.Platform; import javafx.geometry.Pos; import javafx.scene.shape.Rectangle; import javafx.scene.paint.Color;
import insidefx.undecorator.Undecorator; import insidefx.undecorator.UndecoratorScene;
public class JXFrameTest3 extends Application { private Stage stage;
public JXFrameTest3() {
super();
}
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
System.out.println( "start");
stage = primaryStage;
BorderPane borderPane = new BorderPane();
HBox box1 = new HBox(2);
Label lab1 = new Label("Name:");
lab1.setMinWidth( Control.USE_PREF_SIZE);
TextField edit1 = new TextField("<name>");
box1.getChildren().addAll( lab1, edit1);
HBox box2 = new HBox(2);
Label lab2 = new Label("Vorname:");
lab2.setMinWidth( Control.USE_PREF_SIZE);
TextField edit2 = new TextField("<vorname>");
box2.getChildren().addAll( lab2, edit2);
VBox box = new VBox(2);
box.getChildren().addAll( box1, box2);
ScrollPane spane = new ScrollPane();
spane.setFitToWidth(true);
spane.setFitToHeight(true);
spane.setContent( box);
Label lab = new Label("Title");
Rectangle rect = new Rectangle(0, 0, 50, 30);
HBox title = new HBox(2);
title.getChildren().addAll( rect, lab);
borderPane.setTop(title);
borderPane.setCenter(spane);
BorderPane.setAlignment(spane, Pos.TOP_LEFT);
UndecoratorScene scene = new UndecoratorScene(stage, StageStyle.UNIFIED, borderPane, null);
stage.setScene(scene);
stage.sizeToScene();
stage.toFront();
stage.show();
}
}
With the following patch at srcdir ./UndecoratorBis-master/src/insidefx/undecorator it works. But I don't know is it good or what's wrong of this code.
please can you help me? Thanks lz
--- Undecorator.java.org 2015-08-14 11:07:47.000000000 +0200 +++ Undecorator.java 2015-08-14 12:25:12.000000000 +0200 @@ -379,7 +379,7 @@ }); }
-
computeAllSizes();
-
//computeAllSizes();
}
/** @@ -465,17 +465,20 @@
@Override protected double computePrefWidth(double d) {
-
return clientArea.getPrefWidth() + SHADOW_WIDTH \* 2 + RESIZE_PADDING \* 2;
-
return super.computePrefWidth(d) + SHADOW_WIDTH \* 2 + RESIZE_PADDING \* 2;
-
//return clientArea.getPrefWidth() + SHADOW_WIDTH * 2 + RESIZE_PADDING * 2;
}
@Override protected double computePrefHeight(double d) {
-
return clientArea.getPrefHeight() + SHADOW_WIDTH \* 2 + RESIZE_PADDING \* 2;
-
return super.computePrefHeight(d) + SHADOW_WIDTH \* 2 + RESIZE_PADDING \* 2;
-
//return clientArea.getPrefHeight() + SHADOW_WIDTH * 2 + RESIZE_PADDING * 2;
}
@Override protected double computeMaxHeight(double d) {
-
return clientArea.getMaxHeight() + SHADOW_WIDTH \* 2 + RESIZE_PADDING \* 2;
-
return super.computeMaxHeight(d) + SHADOW_WIDTH \* 2 + RESIZE_PADDING \* 2;
-
//return clientArea.getMaxHeight() + SHADOW_WIDTH * 2 + RESIZE_PADDING * 2;
}
@Override @@ -487,7 +490,8 @@
@Override protected double computeMaxWidth(double d) {
-
return clientArea.getMaxWidth() + SHADOW_WIDTH \* 2 + RESIZE_PADDING \* 2;
-
return super.computeMaxWidth(d) + SHADOW_WIDTH \* 2 + RESIZE_PADDING \* 2;
-
//return clientArea.getMaxWidth() + SHADOW_WIDTH * 2 + RESIZE_PADDING * 2;
}
@Override --- stageUtilityDecoration.fxml.org 2015-08-14 11:07:52.000000000 +0200 +++ stageUtilityDecoration.fxml 2015-08-14 11:08:49.000000000 +0200 @@ -10,7 +10,7 @@
-<AnchorPane id="decorationRoot" fx:id="decorationRoot" maxHeight="-1.0" maxWidth="-1.0" minHeight="-1.0" minWidth="-1.0" pickOnBounds="false" prefHeight="400.0" prefWidth="600.0" snapToPixel="true" styleClass="decoration-resize" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
+<AnchorPane id="decorationRoot" fx:id="decorationRoot" maxHeight="-1.0" maxWidth="-1.0" minHeight="-1.0" minWidth="-1.0" pickOnBounds="false" prefHeight="-1" prefWidth="-1" snapToPixel="true" styleClass="decoration-resize" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
-<AnchorPane id="decorationRoot" fx:id="decorationRoot" maxHeight="-1.0" maxWidth="-1.0" minHeight="-1.0" minWidth="-1.0" pickOnBounds="false" prefHeight="400.0" prefWidth="600.0" snapToPixel="true" styleClass="decoration-resize" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
+<AnchorPane id="decorationRoot" fx:id="decorationRoot" maxHeight="-1.0" maxWidth="-1.0" minHeight="-1.0" minWidth="-1.0" pickOnBounds="false" prefHeight="-1" prefWidth="-1" snapToPixel="true" styleClass="decoration-resize" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">