title: Different sizes in JavaFX on different screens
body: <p>I've been struggling to make my JavaFX application size properly on different devices. I think it happens because of different resolutions on the screens. I'm doing all the development on my Macbook Pro Retina 13, which has a resolution of <code>2560x1600</code>, while the window looks different on my Windows desktop which runs <code>1920x1080</code>. I'll illustrate with two pictures.</p>
  <h2>2560x1600</h2>
  <p><img src="https://i.stack.imgur.com/TzNAN.png" alt="2560x1600" /></p>
  <h2>1920x1080</h2>
  <p><img src="https://i.stack.imgur.com/mQAP2.png" alt="1920x1080" /></p>
  <p>My first guess was that it was because the BorderPane would increase in size on 1920x1080. So I tried to fix the size with the following code.</p>
  <pre><code>&lt;BorderPane maxHeight=&quot;304.0&quot; maxWidth=&quot;414.0&quot; minHeight=&quot;304.0&quot; 
  minWidth=&quot;414.0&quot; prefHeight=&quot;304.0&quot; prefWidth=&quot;414.0&quot; 
  xmlns=&quot;http://javafx.com/javafx/8.0.40&quot; 
  xmlns:fx=&quot;http://javafx.com/fxml/1&quot; fx:controller=&quot;controller.GUIController&quot;&gt;
  </code></pre>
  <p>This didn't change anything, though. Any ideas how to address this problem?</p>
  <p><strong>EDIT:</strong> I want it to look like on <code>2560x1600</code> basically.</p>
  <p><strong>EDIT:</strong> The FXML file looks like the following.</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  
  &lt;?import javafx.geometry.*?&gt;
  &lt;?import javafx.scene.text.*?&gt;
  &lt;?import javafx.scene.control.*?&gt;
  &lt;?import java.lang.*?&gt;
  &lt;?import javafx.scene.layout.*?&gt;
  &lt;?import javafx.scene.layout.AnchorPane?&gt;
  
  &lt;AnchorPane xmlns=&quot;http://javafx.com/javafx/8.0.40&quot; xmlns:fx=&quot;http://javafx.com/fxml/1&quot; fx:controller=&quot;controller.GUIController&quot;&gt;
     &lt;children&gt;
        &lt;BorderPane&gt;
           &lt;center&gt;
              &lt;ScrollPane BorderPane.alignment=&quot;CENTER&quot;&gt;
                &lt;content&gt;
                  &lt;AnchorPane&gt;
                       &lt;children&gt;
                          &lt;TableView fx:id=&quot;itemList&quot; prefHeight=&quot;214.0&quot; prefWidth=&quot;412.0&quot;&gt;
                            &lt;columns&gt;
                              &lt;TableColumn fx:id=&quot;nameColumn&quot; editable=&quot;false&quot; resizable=&quot;false&quot; text=&quot;Name&quot; /&gt;
                              &lt;TableColumn fx:id=&quot;powerColumn&quot; editable=&quot;false&quot; resizable=&quot;false&quot; text=&quot;Power&quot; /&gt;
                                &lt;TableColumn fx:id=&quot;typeColumn&quot; editable=&quot;false&quot; resizable=&quot;false&quot; text=&quot;Type&quot; /&gt;
                            &lt;/columns&gt;
                             &lt;columnResizePolicy&gt;
                                &lt;TableView fx:constant=&quot;CONSTRAINED_RESIZE_POLICY&quot; /&gt;
                             &lt;/columnResizePolicy&gt;
                          &lt;/TableView&gt;
                       &lt;/children&gt;
                    &lt;/AnchorPane&gt;
                &lt;/content&gt;
              &lt;/ScrollPane&gt;
           &lt;/center&gt;
           &lt;bottom&gt;
              &lt;HBox alignment=&quot;CENTER_LEFT&quot; BorderPane.alignment=&quot;CENTER&quot;&gt;
                 &lt;children&gt;
                    &lt;HBox prefHeight=&quot;40.0&quot; prefWidth=&quot;6.0&quot; /&gt;
                    &lt;Label prefHeight=&quot;17.0&quot; prefWidth=&quot;37.0&quot; text=&quot;Item: &quot;&gt;
                       &lt;font&gt;
                          &lt;Font name=&quot;System Regular&quot; size=&quot;12.0&quot; /&gt;
                       &lt;/font&gt;
                    &lt;/Label&gt;
                    &lt;ComboBox fx:id=&quot;newCBox&quot; onAction=&quot;#addItemClicked&quot; prefHeight=&quot;27.0&quot; prefWidth=&quot;112.0&quot; promptText=&quot;New&quot; /&gt;
                    &lt;HBox prefHeight=&quot;40.0&quot; prefWidth=&quot;40.0&quot; /&gt;
                    &lt;Button mnemonicParsing=&quot;false&quot; onAction=&quot;#importClicked&quot; prefHeight=&quot;27.0&quot; prefWidth=&quot;64.0&quot; text=&quot;Import&quot; /&gt;
                    &lt;HBox prefHeight=&quot;40.0&quot; prefWidth=&quot;5.0&quot; /&gt;
                    &lt;Button mnemonicParsing=&quot;false&quot; onAction=&quot;#removeClicked&quot; prefHeight=&quot;27.0&quot; prefWidth=&quot;68.0&quot; text=&quot;Remove&quot; /&gt;
                    &lt;HBox prefHeight=&quot;40.0&quot; prefWidth=&quot;5.0&quot; /&gt;
                    &lt;Button mnemonicParsing=&quot;false&quot; onAction=&quot;#upgradeClicked&quot; prefHeight=&quot;27.0&quot; prefWidth=&quot;72.0&quot; text=&quot;Upgrade&quot; /&gt;
                 &lt;/children&gt;
              &lt;/HBox&gt;
           &lt;/bottom&gt;
           &lt;top&gt;
              &lt;VBox alignment=&quot;CENTER_RIGHT&quot; prefHeight=&quot;58.0&quot; prefWidth=&quot;414.0&quot; BorderPane.alignment=&quot;CENTER&quot;&gt;
                 &lt;children&gt;
                    &lt;MenuBar&gt;
                      &lt;menus&gt;
                        &lt;Menu mnemonicParsing=&quot;false&quot; text=&quot;File&quot;&gt;
                          &lt;items&gt;
                            &lt;MenuItem fx:id=&quot;savedMenu&quot; mnemonicParsing=&quot;false&quot; onAction=&quot;#saveClicked&quot; text=&quot;Save&quot; /&gt;
                                &lt;SeparatorMenuItem mnemonicParsing=&quot;false&quot; /&gt;
                                &lt;MenuItem fx:id=&quot;openMenu&quot; mnemonicParsing=&quot;false&quot; onAction=&quot;#openClicked&quot; text=&quot;Open&quot; /&gt;
                          &lt;/items&gt;
                        &lt;/Menu&gt;
                          &lt;Menu mnemonicParsing=&quot;false&quot; text=&quot;Item&quot;&gt;
                            &lt;items&gt;
                                &lt;MenuItem fx:id=&quot;editItemMenu&quot; mnemonicParsing=&quot;false&quot; onAction=&quot;#editItemClicked&quot; text=&quot;Edit&quot; /&gt;
                                &lt;SeparatorMenuItem mnemonicParsing=&quot;false&quot; /&gt;
                              &lt;MenuItem fx:id=&quot;importMenu&quot; mnemonicParsing=&quot;false&quot; onAction=&quot;#importClicked&quot; text=&quot;Import&quot; /&gt;
                                &lt;SeparatorMenuItem mnemonicParsing=&quot;false&quot; /&gt;
                                &lt;MenuItem fx:id=&quot;removeMenu&quot; mnemonicParsing=&quot;false&quot; onAction=&quot;#removeClicked&quot; text=&quot;Remove&quot; /&gt;
                                &lt;SeparatorMenuItem mnemonicParsing=&quot;false&quot; /&gt;
                                &lt;MenuItem fx:id=&quot;upgradeMenu&quot; mnemonicParsing=&quot;false&quot; onAction=&quot;#upgradeClicked&quot; text=&quot;Upgrade&quot; /&gt;
                            &lt;/items&gt;
                          &lt;/Menu&gt;
                        &lt;Menu mnemonicParsing=&quot;false&quot; text=&quot;Profile&quot;&gt;
                          &lt;items&gt;
                            &lt;MenuItem id=&quot;editValues&quot; fx:id=&quot;editValues&quot; mnemonicParsing=&quot;false&quot; onAction=&quot;#editValuesClicked&quot; text=&quot;Edit &amp;amp; New&quot; /&gt;
                                &lt;SeparatorMenuItem mnemonicParsing=&quot;false&quot; /&gt;
                                &lt;MenuItem mnemonicParsing=&quot;false&quot; onAction=&quot;#shareProfileClicked&quot; text=&quot;Share Profile&quot; /&gt;
                                &lt;SeparatorMenuItem mnemonicParsing=&quot;false&quot; /&gt;
                                &lt;MenuItem mnemonicParsing=&quot;false&quot; onAction=&quot;#loadProfileClicked&quot; text=&quot;Load Profile&quot; /&gt;
                                &lt;SeparatorMenuItem mnemonicParsing=&quot;false&quot; /&gt;
                                &lt;MenuItem mnemonicParsing=&quot;false&quot; onAction=&quot;#removeProfileClicked&quot; text=&quot;Remove&quot; /&gt;
                          &lt;/items&gt;
                        &lt;/Menu&gt;
                        &lt;Menu mnemonicParsing=&quot;false&quot; text=&quot;Help&quot;&gt;
                          &lt;items&gt;
                            &lt;MenuItem mnemonicParsing=&quot;false&quot; onAction=&quot;#aboutClicked&quot; text=&quot;About&quot; /&gt;
                                &lt;SeparatorMenuItem mnemonicParsing=&quot;false&quot; /&gt;
                                &lt;MenuItem mnemonicParsing=&quot;false&quot; onAction=&quot;#newsClicked&quot; text=&quot;News&quot; /&gt;
                          &lt;/items&gt;
                        &lt;/Menu&gt;
                      &lt;/menus&gt;
                    &lt;/MenuBar&gt;
                    &lt;HBox alignment=&quot;CENTER_LEFT&quot;&gt;
                       &lt;children&gt;
                          &lt;HBox prefHeight=&quot;31.0&quot; prefWidth=&quot;5.0&quot; /&gt;
                          &lt;Label text=&quot;Display: &quot; /&gt;
                          &lt;ComboBox fx:id=&quot;displayCBox&quot; onAction=&quot;#displayChanged&quot; prefHeight=&quot;27.0&quot; prefWidth=&quot;149.0&quot; promptText=&quot;Display type&quot; /&gt;
                          &lt;HBox prefHeight=&quot;31.0&quot; prefWidth=&quot;59.0&quot; /&gt;
                          &lt;ComboBox fx:id=&quot;profileCBox&quot; onAction=&quot;#profileChanged&quot; prefHeight=&quot;27.0&quot; prefWidth=&quot;143.0&quot; promptText=&quot;Choose Profile&quot; /&gt;
                       &lt;/children&gt;
                    &lt;/HBox&gt;
                 &lt;/children&gt;
              &lt;/VBox&gt;
           &lt;/top&gt;
        &lt;/BorderPane&gt;
     &lt;/children&gt;
  &lt;/AnchorPane&gt;
  </code></pre>