问题
I have a FlowPane which will hold many panels which are based on BorderPane.
I want to create ComboBox which will be used to filter the Panels by type. And the panels will be scrolled by ScrollPanewhen they exceed the visible area.
I want the combo box to scroll along with the FlowPane inside the ScrollPane. I want to get the result which is displayed into the picture. Can you tell me how I can get the desired result. I can very easy create BorderPanes and insert them into the FlowPane and the challenge is how to position the Combo Box and keep it always at this position.
回答1:
Why don't you simply use another border pane?
- Add your combobox to the top ( or additional flow pane with combobox on it)
- Add your Flowpane to the Center
- Then scroll the whole border pane using the scrollpane?
What could be simpler?
回答2:
Here's how you'd do it:
StackPane with 2 layers:
- layer1: your ComboBox panel.
- layer2: your ScrollPane with your FlowPane inside*.
*The trick is: just make your combobox panel background opaque, and some initial top inset on the flowpane so that it starts at the right place.
来源:https://stackoverflow.com/questions/18229444/add-fixed-positioned-combobox-inside-flowpane