Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
313 views
in Technique[技术] by (71.8m points)

java - JavaFX HBox hide item

How can i hide an item in HBox, and made space used by this item available to other items.

TitledPane legendPane = new TitledPane("Legend", _legend);
legendPane.setVisible(false);
LineChart chart = new LineChart<Number, Number>(_xAxis, _yAxis);

HBox hbox = new HBox(5);
hbox.getChildren().addAll(legendPane, chart);

In the above code i want the chart node to use all available space when the legend pane is hidden.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Before calling legendPane.setVisible, call:

legendPane.managedProperty().bind(legendPane.visibleProperty());

The Node.managed property prevents a node in a Scene from affecting the layout of other scene nodes.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...