In my JavaFX FXML application when I set resizable to false and maximized to true the window becomes maximized but the taskbar gets hidden. I am using Netbeans 8.0.2 on Windows 7 64 Bit with JDK 1.8.60
In Netbeans I followed the steps to create a new JavaFX FXML application. To the default code generated I added the following two lines in the start function.
stage.setResizable(false);
stage.setMaximized(true);
Hence the final start function is as below
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().
getResource("FXMLDocument.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.setResizable(false);
stage.setMaximized(true);
stage.show();
}
Now when I run the application the window is maximized, title bar is visible but the task bar is not visible. How should I fix this i.e. make the task bar visible?
@JC997 Has a great answer but I want to refine.
While using setWidth and setHeight you do not preventing your user from resizing the whole window. Combining setResizeable(false) with the following code won't help in that case neither.
You should apply Min and Max values to actually achieve what you are looking for, use this
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
stage.setX(primaryScreenBounds.getMinX());
stage.setY(primaryScreenBounds.getMinY());
stage.setMaxWidth(primaryScreenBounds.getWidth());
stage.setMinWidth(primaryScreenBounds.getWidth());
stage.setMaxHeight(primaryScreenBounds.getHeight());
stage.setMinHeight(primaryScreenBounds.getHeight());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With