1

I made Button with max width of 300 and input a long text in it. Button got max size, but FlowPane, which also has max size of 300, grew in width. How comes that Button text is affecting FlowPane width? How to prevent it from happening?
Screenshot:

FlowPane is marked with yellow border.

Button settings:

enter image description here

FlowPane settings:

enter image description here

Alyona
  • 1,682
  • 2
  • 21
  • 44

1 Answers1

0

Place the FlowPane inside an AnchorPane. Set the AnchorPane sizes to the FlowPane sizes. At the very least, set the left and right AnchorPane constraints of the FlowPane to 0.

enter image description here

Is FlowPane really the Node you want here?

SedJ601
  • 12,173
  • 3
  • 41
  • 59
  • I guess, as long as I have one button there, I can use `AnchorPane` for that. But in cases if I would need it for several elements? Why it's being stretched by text inside of my button even though it has it's max width? Is it a bug? – Alyona Jul 06 '17 at 16:19
  • I have no Idea why it is displaying this behavior or if it's a bug. Reading [this](https://docs.oracle.com/javase/8/javafx/api/javafx/scene/layout/FlowPane.html) may help. – SedJ601 Jul 06 '17 at 16:26