-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
8
-
SUSE Linux 11 64bit
Scene can shrink to 2-pixel size when it contains an empty group or a non-empty group which resizes itself with changes to scene size (using ChangeListener or InvalidationListener).
To reproduce, run the following application (you can modify it to try different cases):
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage stage) {
//Rectangle r = new Rectangle(100, 100, Color.ALICEBLUE);
Pane box = new Pane();
box.setStyle("-fx-border-color: red;");
//box.getChildren().add(r);
Scene scene = new Scene(box);
scene.widthProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) {
System.out.println("Scene width changed from " + t + " to " + t1);
//box.setPrefWidth((double) t1);
}
});
scene.heightProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) {
System.out.println("Scene height changed from " + t + " to " + t1);
//box.setPrefHeight((double) t1);
}
});
stage.widthProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) {
System.out.println("Stage width changed from " + t + " to " + t1);
}
});
stage.heightProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) {
System.out.println("Stage height changed from " + t + " to " + t1);
}
});
stage.setScene(scene);
stage.setWidth(800);
stage.setHeight(600);
stage.sizeToScene();
stage.show();
}
}
To reproduce, run the following application (you can modify it to try different cases):
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage stage) {
//Rectangle r = new Rectangle(100, 100, Color.ALICEBLUE);
Pane box = new Pane();
box.setStyle("-fx-border-color: red;");
//box.getChildren().add(r);
Scene scene = new Scene(box);
scene.widthProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) {
System.out.println("Scene width changed from " + t + " to " + t1);
//box.setPrefWidth((double) t1);
}
});
scene.heightProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) {
System.out.println("Scene height changed from " + t + " to " + t1);
//box.setPrefHeight((double) t1);
}
});
stage.widthProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) {
System.out.println("Stage width changed from " + t + " to " + t1);
}
});
stage.heightProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) {
System.out.println("Stage height changed from " + t + " to " + t1);
}
});
stage.setScene(scene);
stage.setWidth(800);
stage.setHeight(600);
stage.sizeToScene();
stage.show();
}
}