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 7691911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:43:53+00:00 2026-05-31T20:43:53+00:00

I´m trying to make a custom component to javafx, so I make my class

  • 0

I´m trying to make a custom component to javafx, so I make my class extends javafx.scene.control.Control and on constructor it draws it´s contents.

My doubts are: how do I make it “grow” to fill all the space available on its parent layout? Like when I place a TextArea instead…

This is an shrink example of what I´m doing:

@Override
public void start(Stage primarystage) throws Exception {
    BorderPane bpane = new BorderPane();
    mainscene = new Scene(bpane, 800, 600);
    ((BorderPane) this.mainscene.getRoot()).setCenter(t);

    primarystage.setScene(mainscene);
    primarystage.show();
}

On this example the TextArea will get all the space the layout provide for it. I want my component do the same!

All I already tried to do:
– Change the properties setMaxWidth/Height, setPrefWidth/Height, setMinWidth/Height; (when I set the MinValues, it always use this values to draw but don´t update the “width” value anymore)
– Tried to use Double.MAX_VALUE to force a bigger size then layout privides;
Everything didn´t work 🙁 I must be mistaking somehow…
– I cried a little too, but even this make nothing work ='(

Maybe a clue is, I put a listener like this below, and everytime I resize my application/stage it updates the TextArea. But when I add this listener do my component it never get update…

TextArea t = new TextArea("teste");
t.widthProperty().addListener(new ChangeListener() {
  public void changed(ObservableValue observable, Object oldValue, Object newValue) {
    System.out.println(oldValue + "|" + newValue);
  }
});

Probably I´m passing by some properties or forgetting something, I don´t know…

I already tried Google, but seems the documentation of JavaFX is too small and superficial, and a lot of them is based on JavaFX script…

I also accepts any tutorial better them the one offered by Oracle…

Thanks in advance of any help… I thing I wrote to much… =O

  • 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-05-31T20:43:55+00:00Added an answer on May 31, 2026 at 8:43 pm

    I found what I was mistaking…

    To make a component grow with it´s parent, all you need to do is define on maxwidth and/or maxheight it max value of double (like below), and let minwidth/height and prefwidth/height with it´s default values.

    this.setMaxWidth(Double.MAX_VALUE);
    this.setMaxHeight(Double.MAX_VALUE);
    

    With this configuration when the parent changes the available space it will use the final method setWidth()/setHeight() to update the width/height your component can use. So, since these methods are final you can´t override it to “know” when a change occurs. You´ll need to add a changelistener like below to be notified when you need to repaint your component.

    t.widthProperty().addListener(new ChangeListener() {
      public void changed(ObservableValue observable, Object oldValue, Object newValue) {
        System.out.println(oldValue + "|" + newValue);
      }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to make my custom TTreeNode Class for example TCustomTreeNode = class(TTreeNode) private
I'm trying to make a custom swing control that is a meter. Swing Meter
I was trying to make a custom application form. I've added some control like
I'm trying to extend a class to eventually make a custom button. I read
I'm trying to make an advanced custom component that should be able to start
i'm trying to make a custom Gallery in my app. I created a class
I'm trying to make a custom control in Silverlight have the same functionality as
I am trying to make Custom RelativeLayout which can scale and scroll. Right now
Trying to make a custom :confirm message for a rails form that returns data
I'm trying to make a custom view in Django admin. I'm reading from this

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.