-
Bug
-
Resolution: Fixed
-
P4
-
jfx11, 8u281
-
x86_64
-
windows_10
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8256709 | 8u291 | Kevin Rushforth | P4 | Resolved | Fixed | b02 |
I'm creating two stages, one as a child of the primary one. The child stage is given a Scene, but the parent isn't. I then move both stages to my second monitor programmatically.
The bug occurs when I try to show the two Stages. Sample code and stack trace below. Uncommenting the "stage.setScene" line works around the problem.
import javafx.application.Application;
import javafx.geometry.Rectangle2D;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.stage.Screen;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
public class NotifyMovingBug extends Application {
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage stage) throws Exception {
Stage childStage = new Stage(StageStyle.TRANSPARENT);
childStage.initOwner(stage);
Screen screen = Screen.getScreens().stream()
.filter(s -> !s.equals(Screen.getPrimary()))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("Must have two screens!"));
setupStageLocation(stage, screen);
setupStageLocation(childStage, screen);
// stage.setScene(new Scene(new Label("Bla")));
childStage.setScene(new Scene(new Label("Some text")));
stage.show(); // <<<< NPE here
childStage.show();
}
private static void setupStageLocation(Stage stage, Screen screen) {
Rectangle2D bounds = screen.getBounds();
stage.setX(bounds.getMinX());
stage.setY(bounds.getMinY());
stage.setWidth(bounds.getWidth());
stage.setHeight(bounds.getHeight());
}
}
Stack trace:
Exception in Application start method
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: Exception in Application start method
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.NullPointerException
at javafx.graphics/com.sun.glass.ui.win.WinWindow.notifyMoving(WinWindow.java:205)
at javafx.graphics/com.sun.glass.ui.win.WinWindow.setBounds(WinWindow.java:129)
at javafx.graphics/com.sun.javafx.tk.quantum.WindowStage.setBounds(WindowStage.java:336)
at javafx.graphics/javafx.stage.Window$TKBoundsConfigurator.apply(Window.java:1550)
at javafx.graphics/javafx.stage.Window.applyBounds(Window.java:1412)
at javafx.graphics/javafx.stage.Window$12.invalidated(Window.java:1117)
at javafx.base/javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:110)
at javafx.base/javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145)
at javafx.graphics/javafx.stage.Window.setShowing(Window.java:1174)
at javafx.graphics/javafx.stage.Window.show(Window.java:1189)
at javafx.graphics/javafx.stage.Stage.show(Stage.java:273)
at NotifyMovingBug.start(NotifyMovingBug.java:32)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
... 1 more
Exception running application NotifyMovingBug
The line of code where this fails in WinWindow is:
view.updateLocation();
Where "view" is null.
The bug occurs when I try to show the two Stages. Sample code and stack trace below. Uncommenting the "stage.setScene" line works around the problem.
import javafx.application.Application;
import javafx.geometry.Rectangle2D;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.stage.Screen;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
public class NotifyMovingBug extends Application {
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage stage) throws Exception {
Stage childStage = new Stage(StageStyle.TRANSPARENT);
childStage.initOwner(stage);
Screen screen = Screen.getScreens().stream()
.filter(s -> !s.equals(Screen.getPrimary()))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("Must have two screens!"));
setupStageLocation(stage, screen);
setupStageLocation(childStage, screen);
// stage.setScene(new Scene(new Label("Bla")));
childStage.setScene(new Scene(new Label("Some text")));
stage.show(); // <<<< NPE here
childStage.show();
}
private static void setupStageLocation(Stage stage, Screen screen) {
Rectangle2D bounds = screen.getBounds();
stage.setX(bounds.getMinX());
stage.setY(bounds.getMinY());
stage.setWidth(bounds.getWidth());
stage.setHeight(bounds.getHeight());
}
}
Stack trace:
Exception in Application start method
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: Exception in Application start method
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.NullPointerException
at javafx.graphics/com.sun.glass.ui.win.WinWindow.notifyMoving(WinWindow.java:205)
at javafx.graphics/com.sun.glass.ui.win.WinWindow.setBounds(WinWindow.java:129)
at javafx.graphics/com.sun.javafx.tk.quantum.WindowStage.setBounds(WindowStage.java:336)
at javafx.graphics/javafx.stage.Window$TKBoundsConfigurator.apply(Window.java:1550)
at javafx.graphics/javafx.stage.Window.applyBounds(Window.java:1412)
at javafx.graphics/javafx.stage.Window$12.invalidated(Window.java:1117)
at javafx.base/javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:110)
at javafx.base/javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145)
at javafx.graphics/javafx.stage.Window.setShowing(Window.java:1174)
at javafx.graphics/javafx.stage.Window.show(Window.java:1189)
at javafx.graphics/javafx.stage.Stage.show(Stage.java:273)
at NotifyMovingBug.start(NotifyMovingBug.java:32)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
... 1 more
Exception running application NotifyMovingBug
The line of code where this fails in WinWindow is:
view.updateLocation();
Where "view" is null.
- backported by
-
JDK-8256709 NPE in WinWindow.notifyMoving when Stage with no Scene is shown on 2nd monitor
- Resolved
- duplicates
-
JDK-8226283 WinWindow.notifyMoving NPE when restoring window size
- Closed
- relates to
-
JDK-8146920 [hidpi] Multi-Monitor issue with HiDpi scaling and undecorated stages
- Resolved
- links to