0

テストのために、これまでのところButtona が aの中にあることを望みます( が含まれていることはわかっています)。NodeTitledPaneAnchorPane

これは、私がメソッドのために試みている一般的なコードです:

@FXML private void alterarTitledPane(MouseEvent event) {

        if (event.isShiftDown()) {

            // Here is where I code for adding a button inside TitledPane                
        }

        if (!titledPane.isExpanded()) {

            titledPane.setExpanded(true);
            titledPane.setText("Expandido");
        }

        else {

            titledPane.setExpanded(false);
            titledPane.setText("No expandido");
        }
}

これらは、それを達成するために私が試した2つの選択肢です。

代替案 1

((AnchorPane)titledPane.getContent()).getChildren().add(button2);
button2.toFront();
button2.setVisible(true); 

代替案 2

Group a = new Group(button2);
((AnchorPane)titledPane.getContent()).getChildren().add(a);
button2.toFront();
button2.setVisible(true);

今のところ結果が出ていません...

4

2 に答える 2

1

ペインにノードを追加するには、まず最初に初期化する必要があります...これを試してください....その仕事。

AnchorPane anch = new AnchorPane();
Button btn = new Button("anshul");
anch.getChildren().add(btn);
于 2013-10-31T12:17:39.703 に答える
0
Anchorpane pane=new Anchorpane();  
Label lbl_user=new Label("Username");  
Textfield txt=new Textfield();  
AnchorPane.setTopAnchor(lbl_user, 10.0);  
AnchorPane.setRightAnchor(lbl_user 10.0);  
AnchorPane.setTopAnchor(txt, 40.0);  
AnchorPane.setRightAnchor(txt,10.0);  
panegetChildren().addAll(lbl_user,txt);
于 2014-02-25T08:25:32.627 に答える