2

I'm currently experimenting with JavaFx 8 and its different Panes.

So I want to implement a hidden Pane with a visible Button which follows a set of rules, for example:

  • The Pane can be placed in 4 positions within its parent: TOP_CENTER, BOTTOM_CENTER, RIGHT_CENTER, LEFT_CENTER; in which the button is placed on top-most or left-most border of the Pane.
  • The Pane is mostly hidden and only the button is visible. If the user clicks on the button, the Pane slides-in. On clicking again, the Pane slides-out again.
  • The background of Pane and Button should be non-transparent, so that its content differs from the main content from parent.

Now follows ASCII-art... ;)

+------------+                            +------------+
|            |                            |            |
|          +-|                            |  +-+-------+
|          |X| (The **X** is the button,  |  |X|#######|
|          +-|  which now was clicked =>) |  +-+#######|
|            |                            |    |#######|
|            |                            |    |#######|
|            |                            |    +-------+
+------------+                            +------------+

My current state is having a StackPane as parent/container and placing a BorderPane with Button on the left and another control centered, which acts as hidden content. The BorderPane is aligned with StackPane.setAlignment(borderPane, Pos.CENTER_RIGHT). The preferred height and width properties are bound to a factor of its parent's (but shown always at the same) size... Also backgrounds are transparent...

Any ideas?

Christian Rädel
  • 581
  • 1
  • 5
  • 13
  • 1
    Look at [ControlsFX](http://fxexperience.com/controlsfx/) for inspiration. `HiddenSidesPane` and `InfoOverlay` might be interesting for you to look at. – Manik Sep 03 '15 at 14:52
  • Yes you need HiddenSidesPane as a base component. It's great. However the default slide out trigger for the HiddenSidesPane uses the position of the mouse pointer... ie when the mouse pointer hovers near the hidden side long enough it causes the slide out animation. The class provides a "pin" method which you can call from a button that you place INSIDE the hiddenSidesPane slide out object. Use a ToggleButton to do this. IMO this is better than having a floating button that takes up space on the screen even when the hidden pane is slide in. – Birdasaur Mar 15 '16 at 13:07
  • However if you really really want a button to show you will have to add the button to the pane and then setLayoutX() to a negative value from the parent container that you are using as the slide out container. – Birdasaur Mar 15 '16 at 13:09

0 Answers0