0

This is a gif of my problem:

enter image description here

As you can see, the button resizes (elevates? and it moves it's outer layout with itself.

This is the hierarchy:

StackPane
    Group // for other content
    Group // The make hbox "wrap-content"
        HBox  // For the 2 buttons
            JfxToggleButton  // "This is test"
            JfxButton    // "Restart" button

The only code to add is that I am positioning the HBox's Group top right of the StackPane, like this:

StackPane.setAlignment(hboxGroup, Pos.TOP_RIGHT)

Only StackPane has this issue, BorderPane does not have it. The reason I am using StackPane is because I want to have the controls on top of the main content.

ToggleButton and HBox have padding.

Actually, padding and alignment do not matter, since the HBox moves relatively regardless.

Btw, I am using jfonix library for button styling.

Thanks for your help.

Edit.:

For those who contribute this problem to JFoenix, this is the same with standard JavaFX controls: (the jump still occurs, only less noticable)

enter image description here

Compared to what I mentioned above, where theHboxhas it's place in the top of a BorderPane, the jump does not happen:

enter image description here

andras
  • 3,305
  • 5
  • 30
  • 45
  • 2
    Looks like the padding on the button changes when it is selected, causing the layout to change... Are you using your own CSS for this? – James_D May 04 '18 at 18:38
  • @James_D the bigger padding might make it more visible, but the problem is that it does not stick to it's place. Also, I am not using my own css. – andras May 05 '18 at 10:17

1 Answers1

0

I realized AnchorPane does not have this problem.

So this the final layout hierarchy:

StackPane
    Group // Content behind
    AnchorPane // That restricts movement, keeps the buttons in place
        Group   // That keeps the background only around the buttons
            HBox // Keeps the buttons next to each other
                ToggleButton
                Button

So I ended up with the problem that AnchorPane does not let clicks through. Which is fixed by setting the AnchorPane

anchorPane.setPickOnBounds(false);
andras
  • 3,305
  • 5
  • 30
  • 45