Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7863823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:36:13+00:00 2026-06-02T23:36:13+00:00

I have a JavaFX 2.0 application with FXML. I want the components (TextFields, ComboBoxes,

  • 0

I have a JavaFX 2.0 application with FXML.
I want the components (TextFields, ComboBoxes, layouts, and so on) to be resized when a window with an application is resized.
So…

  • As it is written on Oracle documentation for JavaFX, to make something like this with shapes, there are a few special properties to shapes:

When building GUI applications with JavaFX, you will notice that certain classes in the API already implement properties. For example, the javafx.scene.shape.Rectangle class contains properties for arcHeight, arcWidth, height, width, x, and y. For each of these properties there will be corresponding methods that match the conventions previously described. For example, getArcHeight(), setArcHeight(double), arcHeightProperty(), which together indicate (to both developers and tools) that the given property exists.*

  • To add listener to a stage I have to do something like:

       stage.resizableProperty().addListener(new ChangeListener<Boolean>(){
        @Override
        public void changed(ObservableValue<? extends Boolean> arg0, Boolean arg1, Boolean arg2){
            throw new UnsupportedOperationException("Not supported yet.");
        }
    
    });
    

So there are two questions:

  • To make some binding I have to get my stage in the controller class. So – how can I get a stage in a controller class?
  • It looks like UI controls do not have any width\height properties, to be bound to something. Or perhaps I have not found them.

So, how can I solve my problem?

UPD. About Scene Builder to Sergey Grinev: When I use Ctrl+K on my component (tell it to occupy the whole area of its parent component) – everything is ok.

But what if I want to tell my component to occupy 50% of an area?
For exammple I have a tab with two VBoxes on it.
The tab’s width is 100px. The Vbox’s widths are 50px for each. VBox1 has x1=0, and x2=50, and VBox2 has x1=50, and x2=100.
Then I resize my window with JavaFX application.
Now I have tab’s Width = 200px.
But my VBoxes widths are still = 50px: VBox1 has x1=0, and x2=50, and VBox2 has x1=150, and x2=200.
And I need them to be VBox1 x1=0 and x2=100 and VBox2 x1=100 and x2=200.
Where x1 and x2 values are the coordinates of VBoxes corners.

How can Scene Builder help me in this situation?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T23:36:14+00:00Added an answer on June 2, 2026 at 11:36 pm

    Another easy option is to use JavaFX Scene Builder (recently become available as public beta: http://www.oracle.com/technetwork/java/javafx/tools/index.html)

    It allows to create UI by drag-and-drop and anchor UI elements to borders (by anchor tool), so they move/resize with the window borders.

    UPDATE:

    To achieve autoresizing percentage layout you can use GridPane with ColumnConstraint:

    public void start(Stage stage) {
    
        VBox box1 = new VBox(1);
        VBox box2 = new VBox(1);
    
        //random content
        RectangleBuilder builder = RectangleBuilder.create().width(20).height(20);
        box1.getChildren().addAll(builder.build(), builder.build(), builder.build());
        builder.fill(Color.RED);
        box2.getChildren().addAll(builder.build(), builder.build(), builder.build());
    
        //half by half screen
        GridPane grid = new GridPane();
        grid.addRow(0, box1, box2);
    
        ColumnConstraints halfConstraint = ColumnConstraintsBuilder.create().percentWidth(50).build();
        grid.getColumnConstraints().addAll(halfConstraint, halfConstraint);
    
        stage.setScene(new Scene(grid, 300, 250));
        stage.show();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application written on JavaFX (with using of FXML). I'm trying to
I have this easy little form in my JavaFX application. I want to use
I have a JavaFX webservice client mobile application. How can I make the JavaFX
I have JavaFX application using FXML to build its GUI. When this application is
I have my JavaFX 2.0 application, where i need to make some action, after
I have just explore javaFX. I am now programming modul based application by netBeans
I have applied CSS style to JavaFX components and it looks like everything is
I have a simple javaFX application that loads a webpage in a WebView componant.
Hi Java programmers. I badly need your help. I have a JavaFX/Java ME application.
I've been researching about building desktop application with JavaFX framework. Does anyone have any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.