Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Right Aligned ToolBar Control - Spacer issue

wzbergerSep 3 2013

When adding a right aligned control to a toolbar I have to add a sping/spacer as described here - however, when an overflow button appears the spacer component is selectable in the overflow popup menu. Is there any way to avoid this behavior? The test below demonstrates the issue.

//see: http://www.oracle.com/technetwork/articles/java/javafxbest2-1634274.html

//section: Implementing Springs and Struts in the UI

public class ToolBarOverflowTest extends Application

{

  public static void main(String[] args)

  {

    Application.launch(ToolBarOverflowTest.class, args);

  }

  @Override

  public void start(Stage stage)

  {

    System.err.println(System.getProperty("javafx.runtime.version"));

    ToolBar toolBar = new ToolBar();

    for (int i = 1; i<6; i++)

      toolBar.getItems().add(new Button("ToolBarButton " + i));

    Region spring = new Region();

    HBox.setHgrow(spring, Priority.ALWAYS);      

    toolBar.getItems().add(spring);

    toolBar.getItems().add(new Button("Right ToolBarButton"));  

    BorderPane root = new BorderPane();

    root.setTop(toolBar);

    Scene scene = new Scene(root, 400, 300);

    stage.setScene(scene);

    stage.show();

  }

}

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 1 2013
Added on Sep 3 2013
0 comments
2,169 views