haakonlu
haakonlu

Reputation: 949

JavaFx 2.0 Menu

I want to have a menu for my program. And I like the standard Menu look and all, but I want to place a "logout-button" on the far right side of the menu-bar.. is it possible to place it there WITHOUT having to fill up the whole menu-bar with entries?

Sincerely

Upvotes: 1

Views: 1245

Answers (1)

Uluk Biy
Uluk Biy

Reputation: 49185

Yes you can. Use the HBox#setHgrow();. This javadoc page also has an example how to use it in "Optional Layout Constraints" section. Following is taken from javadoc.

For example, if an hbox needs the TextField to be allocated all extra space:

     HBox hbox = new HBox();
     TextField field = new TextField();
     HBox.setHgrow(field, Priority.ALWAYS);
     hbox.getChildren().addAll(new Label("Search:"), field, new Button("Go"));

Briefly speaking, set Priority.ALWAYS for the button (or any control) just before the "logout-button" in a HBox. More advanced example is here: Using Built-In Layout Panes : Example 1-4

Upvotes: 2

Related Questions