Reputation: 2503
I've create this in scene builder :
My goal is to make this a little more beautiful :
Problem 1 : Put the close button in MAX RIGHT
Problem 2 : Stick the differents layouts and TextArea to the window border, because when I resize my window, component does not move.
To do so I want to manipulate the layout properties, but I don't really know how. I was thinking of using spacing for my problem one, but it seems complicated, and I have no idea for resolving my second problem.
Is the choice of my layout correct ? What properties do I have to use for resolving my problems ?
Thanks.
Upvotes: 0
Views: 119
Reputation: 49185
IMO using StackPane
for top layout is more appropriate:
@Override
public void start( Stage stage )
{
Button b = new Button( "Close" );
Label l = new Label( "Console" );
StackPane sp = new StackPane( l, b );
StackPane.setAlignment( l, Pos.CENTER_LEFT );
StackPane.setAlignment( b, Pos.CENTER_RIGHT );
TextArea area = new TextArea();
VBox.setVgrow( area, Priority.ALWAYS );
VBox box = new VBox( sp, area );
Scene scene = new Scene( box, 800, 600 );
stage.setScene( scene );
stage.show();
}
But using of HBox
is unavoidable, add another element to it as a spacer:
@Override
public void start( Stage stage )
{
Button b = new Button( "Close" );
Label l = new Label( "Console" );
Pane spacer = new Pane();
HBox hBox = new HBox(l, spacer, b);
HBox.setHgrow( spacer, Priority.ALWAYS);
TextArea area = new TextArea();
VBox.setVgrow( area, Priority.ALWAYS );
VBox box = new VBox( hBox, area );
Scene scene = new Scene( box, 800, 600 );
stage.setScene( scene );
stage.show();
}
Upvotes: 1