---
title: JavaFX 2.0 Resizing of UI Controls
description: JavaFX 2.0 Resizing of UI Controls
---

[![e-Zest logo\_An accion lab company\_Colour](https://blog.e-zest.com/hubfs/images/Logos%20with%20Tagline/Corporate/SVG/e-Zest%20logo_An%20accion%20lab%20company_Colour.svg "e-Zest logo_An accion lab company_Colour")](https://www.e-zest.com/)

- [WORK](https://www.e-zest.com/our-work)
- [SERVICES](https://www.e-zest.com/our-services) 
    - [Product Engineering](https://www.e-zest.com/digital-product-engineering-services)
    - [Enterprise Data Services](https://www.e-zest.com/enterprise-data-services)
    - [Digital Commerce](https://www.e-zest.com/digital-commerce-services)
    - [Digital Operations](https://www.e-zest.com/digital-operations)
    - [Digital Consulting](https://www.e-zest.com/digital-transformation-consulting-services)
    - [Digital Experience Design](https://www.e-zest.com/digital-experience-design)
- [INSIGHTS](https://blog.e-zest.com/)
- [CAREERS](https://www.e-zest.com/careers)
- [ENTERPRISE DATA SERVICES](https://www.e-zest.com/enterprise-data-services)
- [GENERATIVE AI](https://www.e-zest.com/generative-ai)
- [Healthcare](https://healthcare.e-zest.com)
- [Contact Us](https://www.e-zest.com/contact-us)

- ![Elevating Product Engineering with AI and ML](https://blog.e-zest.com/hubfs/Elevating%20Product%20Engineering%20with%20AI%20and%20ML.jpg)

  [BLOGS](https://blog.e-zest.com)
  
  #### Elevating Product Engineering with AI and ML

  As technology evolves and customer choices broaden, there is an increasing ...

  [Read more](https://blog.e-zest.com/elevating-product-engineering-with-ai-and-ml)
- ![e-Zest – An Accion Labs Company gets Recognition as a Contender in the ISG Provider Lens™ Study on Digital Engineering Services 2024](https://blog.e-zest.com/hubfs/e-Zest%20%E2%80%93%20An%20Accion%20Labs%20Company%20-%20Gets%20Recognition%20as%20a%20Contender%20in%20the%20ISG%20Provider%20LensTM%20Study%20on%20Digital%20Engineering%20Services%202024.jpg)

  [NEWS](https://blog.e-zest.com/news)
  
  #### e-Zest – An Accion Labs Company gets Recognition as a Contender in the ISG Provider Lens™ Study on Digital Engineering Services 2024

  We are delighted to announce that e-Zest – An Accion Labs Company has been ...

  [Read more](https://blog.e-zest.com/news/e-zest-an-accion-labs-company-gets-recognition-as-a-contender-in-the-isg-provider-lens-study-on-digital-engineering-services-2024)
- ![e-Zest Solutions supports Digital Pune Mission](https://blog.e-zest.com/hubfs/blog-files/Digital%20Literacy%20Bus%20e-Zest.png)

  [CSR](https://blog.e-zest.com/csr)
  
  #### e-Zest Solutions supports Digital Pune Mission

  **Pune, India:** e-Zest Solutions, a leading digital technology innovation ...

  [Read more](https://blog.e-zest.com/csr/e-zest-solutions-supports-digital-pune-mission)

- [Work](https://www.e-zest.com/our-work)
- [Services](https://www.e-zest.com/our-services)
- [Insights](https://blog.e-zest.com)
- [Careers](https://www.e-zest.com/careers)
- [Enterprise Data](https://www.e-zest.com/enterprise-data-services)
- [Generative AI](https://www.e-zest.com/generative-ai)
- [Innovations](https://www.e-zest.com/innovations)
- [Healthcare](https://healthcare.e-zest.com)
- [About](https://www.e-zest.com/about-us)
- [Contact](https://www.e-zest.com/contact-us)

- [Blog](https://blog.e-zest.com/)
- [News](https://blog.e-zest.com/news)
- [CSR](https://blog.e-zest.com/csr)

- [![Linkedin Icon](https://blog.e-zest.com/hubfs/icons/linkedin_icon_white.svg)](https://www.linkedin.com/company/e-zest-solutions/)
- [![Twitter Icon](https://blog.e-zest.com/hubfs/twitter-logo-silhouette%20(5).svg)](https://twitter.com/ezest)
- [![Facebook Icon](https://blog.e-zest.com/hubfs/facebook-app-logo%20(4).svg)](https://www.facebook.com/61259256638)
- [![Instagram Icon](https://blog.e-zest.com/hubfs/instagram-logo%20(4).svg)](https://www.instagram.com/ezestsolutions/)
- [![Youtube Icon](https://blog.e-zest.com/hubfs/icons/youtube_icon_white.svg)](https://www.youtube.com/user/ezestcorporate)

[![Go to top icon](https://blog.e-zest.com/hubfs/AA%20Assets/top%20button.svg)](https://blog.e-zest.com/javafx-20-resizing-of-ui-controls/#top)

Hit enter to search or ESC to close

Insights

e-Zest members share technology ideas to foster digital transformation.

- [Blog](https://blog.e-zest.com)
- [News](https://blog.e-zest.com/news)
- [Podcasts](https://www.e-zest.com/podcasts)
- [Healthcare](https://blog.e-zest.com/healthcare)
- [CSR](https://blog.e-zest.com/csr)
- [Whitepaper](https://blog.e-zest.com/whitepaper)
- [Playbook](https://blog.e-zest.com/playbook)
- [Media Kit](https://www.e-zest.com/media-kit)

# JavaFX 2.0 Resizing of UI Controls

[Nitin Gupta](https://blog.e-zest.com/author/nitin-gupta)  Feb 15, 2012

[javafx 2.0](https://blog.e-zest.com/topic/javafx-2-0) [Technology](https://blog.e-zest.com/topic/technology) [java desktop development](https://blog.e-zest.com/topic/java-desktop-development-2)

- <https://www.linkedin.com/shareArticle?mini=true&url=https://blog.e-zest.com/javafx-20-resizing-of-ui-controls/&title=&summary=&source=>
- <https://twitter.com/intent/tweet?source=https://blog.e-zest.com/javafx-20-resizing-of-ui-controls/&text=JavaFX%202.0%20Resizing%20of%20UI%20Controls>
- <https://www.facebook.com/sharer/sharer.php?u=https://blog.e-zest.com/javafx-20-resizing-of-ui-controls/>
- <https://www.instagram.com/ezestsolutions/?u=https://blog.e-zest.com/javafx-20-resizing-of-ui-controls/>

**Resizing of the Root**

Everything that extends Region or Control and is set as the root will automatically fit to the Scene. Anything that extends Group will not.

If you do not want the application to resize with the scene, add a Group as the root.

**Resizing of Child Nodes**

The size of a resizable node (Region, Control, WebView) will depend on two things:

1. It's own min/pref/max size preferences
2. The sizing policy of its parent

**Following is a brief description of how the various nodes will be resized if the following are the Parent containers:**

**FlowPane**: FlowPane will always resize nodes to their preferred sizes. This means controls added to a flowpane won’t resize if you resize the application window. FlowPane should contain only those controls for which resizing is not required.

**StackPane**: StackPane will attempt to resize its children to fill its area (up to the child's max size limits).This means that a node’s default MAX size has everything to do with how its resize.

All Layout panes and most of the controls have an unbounded max size, which means a StackPane will stretch them out. The exceptions:

- Label, Buttons, Hyperlink, Slider, ProgressBar returns pref size for max (so they don't stretch by default)
- MenuBar, TextBox return pref for max height (width is unbounded)

If you don't want a GridPane to be stretched beyond its preferred size, just clamp it:  
`gridpane.setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);`

If you want a Button's width to be flexible:  
`button.setMaxWidth(Double.MAX_VALUE);`

**GridPane:**

The sizing of rows and columns in a GridPane will depend on the percentage width set for the CoulmnConstraints and percentage height set for the RowContraints. The code below sets the percentage with for column 1 and 2 and percentage height of rows 1 to 4

`ColumnConstraints column1 = new ColumnConstraints();`

`column1.setPercentWidth(50);`

`ColumnConstraints column2 = new ColumnConstraints();`

`column2.setPercentWidth(50);`

`configurationPane.getColumnConstraints().addAll(column1, column2);`

`RowConstraints rowConstraints1=new RowConstraints();`

`rowConstraints1.setPercentHeight(30);`

`RowConstraints rowConstraints2=new RowConstraints();`

`rowConstraints2.setPercentHeight(30);`

`RowConstraints rowConstraints3=new RowConstraints();`

`rowConstraints3.setPercentHeight(30);`

`RowConstraints rowConstraints4=new RowConstraints();`

`rowConstraints4.setPercentHeight(10);`

`configurationPane.getRowConstraints().`

`addAll(rowConstraints1,rowConstraints2,rowConstraints3,rowConstraints4);`

Once the rows and columns of Grid are resized the sizing of the nodes within each of them would behave based on the resizing policy of the controls as discussed under stack pane.

**VBox:**

The setVgrow method sets the vertical grow priority for the child when contained by an VBox. If set, the VBox will use the priority to allocate additional space if the VBox is resized larger than its preferred height. If multiple VBox children have the same vertical grow priority, then the extra space will be split evening between them. If no vertical grow priority is set on a child, the VBox will never allocate it additional vertical space if available. Setting the value to null will remove the constraint.

**HBox:**

The setHgrow method sets the horizontal grow priority for the child when contained by an HBox. If set, the HBox will use the priority to allocate additional space if the HBox is resized larger than its preferred width. If multiple HBox children have the same horizontal grow priority, then the extra space will be split evening between them. If no horizontal grow priority is set on a child, the HBox will never allocate it additional horizontal space if available. Setting the value to null will remove the constraint

**BorderPane:**

Border Pane again uses the resizing policy of the nodes as discussed under stack pane to resize the nodes.

**Left Node:** If the node placed on the left edge of the border pane is resizable, it will be resized to its preferred width and the height will span the height of the border pane between the top and bottom nodes. If the node cannot be resized to fill the left space (it's not resizable or its max size prevents it) then it will be aligned top-left within the space unless the child's alignment constraint has been set.

**Right Node:** If the node placed on the right edge of this border pane is resizable, it will be resized to its preferred width and its height will span the height of the border pane between the top and bottom nodes. If the node cannot be resized to fill the right space (it's not resizable or its max size prevents it) then it will be aligned top-right within the space unless the child's alignment constraint has been set.

**Top Node:** If the node placed on the top edge of this border pane is resizable, it will be resized to its preferred height and its width will span the width of the border pane. If the node cannot be resized to fill the top space (it's not resizable or its max size prevents it) then it will be aligned top-left within the space unless the child's alignment constraint has been set.

**Bottom Node:** If the node placed on the bottom edge of the border pane is resizable, it will be resized to its preferred height and its width will span the width of the border pane. If the node cannot be resized to fill the bottom space (it's not resizable or its max size prevents it) then it will be aligned bottom-left within the space unless the child's alignment constraint has been set.

**References:**

[JavaFX](https://blog.e-zest.com/javafx/) JavaDocs: [http://download.oracle.com/javafx/2.0/api/index.html](http://download.oracle.com/javafx/2.0/api/index.html)

- <https://twitter.com/intent/tweet?source=https://blog.e-zest.com/javafx-20-resizing-of-ui-controls/&text=JavaFX%202.0%20Resizing%20of%20UI%20Controls>
- <https://www.facebook.com/sharer/sharer.php?u=https://blog.e-zest.com/javafx-20-resizing-of-ui-controls/>
- <https://www.linkedin.com/shareArticle?mini=true&url=https://blog.e-zest.com/javafx-20-resizing-of-ui-controls/&title=&summary=&source=>

### Similar Blog

[![Gradients In JavaFX](https://blog.e-zest.com/hs-fs/file-3395198484-png/blog-files/linear-gradient-1.png)](https://blog.e-zest.com/gradients-in-javafx-2/)

[Gradients In JavaFX](https://blog.e-zest.com/gradients-in-javafx-2/)

[One of the very interesting features of](https://blog.e-zest.com/gradients-in-javafx-2/)[JavaFX](https://blog.e-zest.com/javafx/) is its ability to have gradients (Linear or Radial) to the background color of the ...

By Sai Dandem Jul 19, 2012

[![Scroller control in JavaFX 2](https://blog.e-zest.com/hs-fs/file-3443237577-png/blog-files/scroller.png)](https://blog.e-zest.com/scroller-control-in-javafx-2/)

[Scroller control in JavaFX 2](https://blog.e-zest.com/scroller-control-in-javafx-2/)

<https://blog.e-zest.com/scroller-control-in-javafx-2/>[JavaFX 2.x](https://blog.e-zest.com/javafx/) has many fascinating and useful controls. Among them “TabPane” is also one of the control. Here I am not going in ...

By Sai Dandem Jun 13, 2012

<https://blog.e-zest.com/javafx-2-x-development-using-fxml/>

[JavaFX 2.x development using FXML](https://blog.e-zest.com/javafx-2-x-development-using-fxml/)

[This post simply explains, development of](https://blog.e-zest.com/javafx-2-x-development-using-fxml/)[JavaFX 2 application](https://blog.e-zest.com/javafx/) using FXML.

By Amol Hingmire May 23, 2012

<https://blog.e-zest.com/ahead-of-time-compilation-for-javafx-2-0-applications/>

[Ahead of Time Compilation for JavaFX 2.0 applications](https://blog.e-zest.com/ahead-of-time-compilation-for-javafx-2-0-applications/)

[We at e-Zest are working on](https://blog.e-zest.com/ahead-of-time-compilation-for-javafx-2-0-applications/)[JavaFX](https://blog.e-zest.com/javafx/) 2.0 for more than a year and are amongst the few early adopters of the technology. Based on ...

By Nitin Gupta May 07, 2012

[![Export Data from SQL Server to Azure Based Snowflake](https://blog.e-zest.com/hubfs/blog-files/Export%20data%20from%20SQL%20server%20to%20Azure%20based%20Snowflake-181220.png) Export Data from SQL Server to Azure Based Snowflake The data export process can broadly be divided into 2 steps: Step 1: Export the data from SQL Server to Azure BlobStep 2: Bulk ... By Nitin Gupta Dec 11, 2018](https://blog.e-zest.com/export-data-from-sql-server-to-azure-based-snowflake)

## [![REST Authentication using OAUTH 2.0 Resource Owner Password Flow protocol](https://blog.e-zest.com/hs-fs/file-3586009710-jpg/blog-files/resource-owner-password-flow.jpg) REST Authentication using OAUTH 2.0 Resource Owner Password Flow protocol Introduction In this blog we will look at how to perform authentication for an application exposing its functionalities as Rest ... By Nitin Gupta Oct 08, 2013](https://blog.e-zest.com/rest-authentication-using-oauth-2-0-resource-owner-password-flow-protocol/)

<https://blog.e-zest.com/ahead-of-time-compilation-for-javafx-2-0-applications/>

[Ahead of Time Compilation for JavaFX 2.0 applications](https://blog.e-zest.com/ahead-of-time-compilation-for-javafx-2-0-applications/)

[We at e-Zest are working on](https://blog.e-zest.com/ahead-of-time-compilation-for-javafx-2-0-applications/)[JavaFX](https://blog.e-zest.com/javafx/) 2.0 for more than a year and are amongst the few early adopters of the technology. Based on ...

By Nitin Gupta May 07, 2012

<https://blog.e-zest.com/osgi-in-practice-part-2-spring-dm-server-2/>

[OSGi in Practice - Part 2 (Spring DM Server )](https://blog.e-zest.com/osgi-in-practice-part-2-spring-dm-server-2/)

[This Blog is in continuation of my](https://blog.e-zest.com/osgi-in-practice-part-2-spring-dm-server-2/)[first blog on OSGi](https://blog.e-zest.com/Blog/post/OSGi-Java-architects-musings-practice-part1.aspx).

By Nitin Gupta Sep 20, 2010

## Helping Organizations Thrive in the Digital Age

[Contact Us](https://www.e-zest.com/contact-us)

- [About](https://www.e-zest.com/about-us)
- [Services](https://www.e-zest.com/our-services)
- [Work](https://www.e-zest.com/our-work)
- [Insights](https://blog.e-zest.com/)
- [Healthcare](https://healthcare.e-zest.com/)
- [Accion Labs](https://www.accionlabs.com/)

- <https://www.linkedin.com/company/e-zest-solutions/>
- <https://twitter.com/ezest>
- <https://www.facebook.com/eZest/>
- <https://www.instagram.com/ezestsolutions/>
- <https://www.youtube.com/user/ezestcorporate>

- Dallas
- Detroit
- Hannover
- Vienna
- London
- Pune

 © 2025 e-Zest Solutions

- [Privacy Policy](https://www.e-zest.com/privacypolicy)
- [Cookie Policy](https://www.e-zest.com/cookie-policy)

 Contact us

 Contact us

e-Zest is a leading digital innovation partner for enterprises and technology companies that utilizes emerging technologies for creating engaging customers experiences. Being a customer-focused and technology-driven company, it always helps clients in crafting holistic business value for their software development efforts. It offers software development and consulting services for cloud computing, enterprise mobility, big data and analytics, user experience and digital commerce.