79390

JavaFX: stage's minHeight considering titlebar's height

Question:

I'm currently building a small UI application for personal purpose and I ran into a problem. Here is some code:

public void start(Stage stage) throws Exception { Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("ui.fxml")); Scene scene = new Scene(root); stage.setTitle("My app"); stage.setScene(scene); stage.setMinHeight(608.0); stage.setMinWidth(1080.0); stage.show(); }

And here's the FXML code assiociated with:

<GridPane gridLinesVisible="true" minHeight="608.0" minWidth="1080.0" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1" fx:controller="my.package.MyClass"> <rowConstraints> <RowConstraints minHeight="500.0" prefHeight="500.0" vgrow="ALWAYS" /> <RowConstraints maxHeight="108.0" minHeight="108.0" prefHeight="108.0" vgrow="NEVER" /> </rowConstraints> </GridPane>

So, my problem is that, at launch, the GridPane will effectively have a height of 608px but is still resizable to a smaller height. Indeed, it will be resizable until the <strong>stage</strong> will be 608px, including the title bar's height...

The behaviour I would like to have is that my GridPane can't have a smaller height than 608.0.

Do you know any ways to do that? Many thanks in advance!

Answer1:

As @James_D pointed out in a comment, I simply had to modify my code as follow:

public void start(Stage stage) throws Exception { Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("ui.fxml")); Scene scene = new Scene(root); stage.setTitle("My app"); stage.setScene(scene); stage.show(); stage.setMinHeight(stage.getHeight()); stage.setMinWidth(stage.getWidth()); }

Recommend

  • Difference between initialized controllers and FXML linked controllers?
  • The table cells are empty in my tableview. JavaFX + Scenebuilder
  • JavaFX 8 Spinner control doesn't update value that's displayed
  • Adding Event listener to mainScene in Javafx using fxml
  • Netbeans: Try to load file but not found (Java)
  • How to aggregate akka-http routes using a trait?
  • Invisible objects because repaint method - Java Swing
  • How to open a resource file in a WAR using a string pathname?
  • Why isn't setIcon displaying image on JButton?
  • clear widget in a QGraphicsScene : crash
  • ScrollPane jumps to top when deleting nodes
  • JavaFX UI blocked while another Thread is running
  • How to get to type parameters of a reflect.runtime.universe.Type in scala? [duplicate]
  • How to allow CKEditor within WebView to access the clipboard?
  • How to extract directory (and sub directories) from jar resource?
  • Android HTTP Authentication
  • Styling tabBar-indicator with ActionBarSherlock
  • How to integrate a custom GraphicsItem into a QML scene?
  • How do I run a function on a specific key press in JavaFX?
  • JavaFX: Align Buttons inside ButtonBar (using SceneBuilder or fxml)
  • Google script gmail addon update TextInput value,on change function
  • SceneKit: Is it possible to cast an shadow on an Transparent Object?
  • Undefined element when tab is not active
  • GUI not updating despite use of validate()
  • GridBagLayout padding
  • logging static methods in a parent class
  • Is there anything like an Objective-C block in Java?
  • Facebook API: cannot login on Android
  • Action Pack components in Rails
  • Bad interaction between Zope2 XML-RPC and AT Image mutator?
  • Read text file that is not in the main package in a runnable jar
  • Java: can you cast Class into a specific interface?
  • Change JButton Shape while respecting Look And Feel
  • req.body is undefined - nodejs
  • recyclerView does not call the onBindViewHolder when scroll in the view
  • Symfony2: How to get request parameter
  • jQuery tmpl and DataLink beta
  • Akka Routing: Reply's send to router ends up as dead letters
  • Is there a mandatory requirement to switch app.yaml?
  • Unable to use reactive element in my shiny app