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
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…