I was writing a game using JavaFX. When I compiled the code using jdk-9, everything worked fine but when I compiled it using jdk-8u102 and ran the program, there was some extra space(about 10 pixels) on the right and bottom of the application window. In both cases the Scene size was correct but in case of java 8, the Stage is bigger on the right and bottom(although inquiring about the width or height of the Stage, using Stage.getWidth() or Stage.getHeight() methods, returns the same values in both cases).
I tried updating to jdk-8u151 but that didn't solve the problem.
Note - When I compiled the program using jdk-8 but ran using jre-9, the problem wasn't there anymore. So I'm guessing, the problem can be with the run time environment of java 8 instead of the jdk itself.
I found that Stage.setResizable(false) is causing the problem in jre-8. Also, I'm using Windows and the problem doesn't seem to be with jre-8 on linux.
Here is a code snippet of the application:
public void start(Stage primaryStage) throws Exception {
ImageView spaceBackground = new ImageView("space.jpg");
spaceBackground.setFitHeight(600);
spaceBackground.setFitWidth(900);
Group group = new Group(spaceBackground);
Scene scene = new Scene(group, 900, 600);
primaryStage.setResizable(false); // this method is causing the problem
/*
rest of the code
*/
}
This is a screen capture of the application window, running under jre-9:
And here is the one running under jre-8:
Can anyone tell me what the cause might be here?