-
Bug
-
Resolution: Unresolved
-
P4
-
8
-
Java8 ea-102 on MS-Windows Seven.
It seems stage.setMaximized(true) is taken into account only after actual on-screen rendering.
The following test code works as-is, but it contains *two* workarounds that should not be necessary:
1) delays SplitPane.setDividerPositions() to after actual scene rendering.
2) forces layout via SplitPane.layout().
The first is absolutely necessary because without it setDividerPositions() is applied to a very small window and fails to properly set dimensions, while the second has "interesting effects": if removed resize will happen only for "root" and only after you click on a divider.
I reported this malfunction also toRT-10376, but I was instructed to "file a separate request"; I hope this is what was meant (it's the first time I use Jira, please bear with me).
================================================
import java.util.Timer;
import java.util.TimerTask;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.geometry.Orientation;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.SplitPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
final SplitPane root = new SplitPane();
root.setOrientation(Orientation.VERTICAL);
final SplitPane child;
{
{
child = new SplitPane();
child.setDividerPositions(0.3);
{
HBox h = new HBox();
h.getChildren().add(new Label("LEFT"));
child.getItems().add(h);
}
{
HBox h = new HBox();
h.getChildren().add(new Label("RIGHT"));
child.getItems().add(h);
}
root.getItems().add(child);
}
{
HBox bottom = new HBox();
bottom.getChildren().add(new Label("Bottom"));
root.getItems().add(bottom);
}
}
root.setDividerPositions(0.8);
Scene s = new Scene(root);
primaryStage.setScene(s);
primaryStage.setMaximized(true);
Timer timer = new Timer(true);
timer.schedule(new TimerTask() {
@Override
public void run() {
Platform.runLater(new Runnable() {
@Override
public void run() {
child.setDividerPositions(0.3);
child.layout(); // fixed by forcing a relayout!!!
root.setDividerPositions(0.8);
}
});
}
}, 1000);
primaryStage.show();
}
}
================================================
The following test code works as-is, but it contains *two* workarounds that should not be necessary:
1) delays SplitPane.setDividerPositions() to after actual scene rendering.
2) forces layout via SplitPane.layout().
The first is absolutely necessary because without it setDividerPositions() is applied to a very small window and fails to properly set dimensions, while the second has "interesting effects": if removed resize will happen only for "root" and only after you click on a divider.
I reported this malfunction also to
================================================
import java.util.Timer;
import java.util.TimerTask;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.geometry.Orientation;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.SplitPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
final SplitPane root = new SplitPane();
root.setOrientation(Orientation.VERTICAL);
final SplitPane child;
{
{
child = new SplitPane();
child.setDividerPositions(0.3);
{
HBox h = new HBox();
h.getChildren().add(new Label("LEFT"));
child.getItems().add(h);
}
{
HBox h = new HBox();
h.getChildren().add(new Label("RIGHT"));
child.getItems().add(h);
}
root.getItems().add(child);
}
{
HBox bottom = new HBox();
bottom.getChildren().add(new Label("Bottom"));
root.getItems().add(bottom);
}
}
root.setDividerPositions(0.8);
Scene s = new Scene(root);
primaryStage.setScene(s);
primaryStage.setMaximized(true);
Timer timer = new Timer(true);
timer.schedule(new TimerTask() {
@Override
public void run() {
Platform.runLater(new Runnable() {
@Override
public void run() {
child.setDividerPositions(0.3);
child.layout(); // fixed by forcing a relayout!!!
root.setDividerPositions(0.8);
}
});
}
}, 1000);
primaryStage.show();
}
}
================================================
- duplicates
-
JDK-8118161 Stage.setMaximized should work even before the Stage is shown
-
- Closed
-