0
我期待在JavaFX 8中实现基本的可扩展自定义控件,其中包含添加了其他控件的窗格。如何实现基于窗格的自定义JavaFX控件
因此,例如,它可以包含GridPane
,其持有TextField
,Button
和CheckBox
。
我不想子类Pane
或GridPane
,因为我不想将这些API公开给用户。所以,“一个由网格窗格组成的节点”与“一个扩展网格窗格的节点”相对。
我看到延伸Region
或Control
是可能的,这是推荐?将窗体大小和布局委派给窗格需要什么?
public class BasePaneControl extends Control {
private final Pane pane;
public BasePaneControl(Pane pane) {
this.pane = pane;
getChildren().add(pane);
}
// What do I need to delegate here to the pane to get sizing
// to affect and be calculated by the pane?
}
public class MyControl extends BasePaneControl {
private final GridPane gp = new GridPane();
public MyControl() {
super(gp);
gp.add(new TextField(), 0, 0);
gp.add(new CheckBox(), 0, 1);
gp.add(new Button("Whatever"), 0, 2);
}
// some methods to manage how the control works.
}
我需要帮忙实施BasePaneControl
以上请。