7

我需要在选择组合框元素时重新绘制一个窗口。如何在 JAVA FX 2.2 中重新绘制窗口(舞台)?

下面是我的代码

functionComboBox.valueProperty().addListener(new ChangeListener<String>() {
    @Override public void changed(ObservableValue ov, String t, String t1) 
    {
        showFunctionParamters(t1);
    }
    private void showFunctionParamters(String methodName) 
    {
        gridPaneParameters = new GridPane();
        gridPaneParameters.setPadding(new Insets(20, 0, 0, 50));
        gridPaneParameters.setHgap(10);
        gridPaneParameters.setVgap(4);
        int i = 2; 
        parameterList = methodAttrMap.get(methodName);
        Iterator<String> itrParameterList = parameterList.iterator();
        while(itrParameterList.hasNext())
        {
            //TODO allow the user to enter the values for the parameters 
            Label parameterName = new Label(itrParameterList.next()); 
            TextField parameterTextField = new TextField();
            gridPaneParameters.add(parameterName, 1, i);
            gridPaneParameters.add(parameterTextField, 2, i);
            i++;
        }
        pane.getChildren().add(gridPaneParameters);
    }
});
4

1 回答 1

13

由于您的代码在运行时将新组件添加到窗格中,因此您可能需要:

pane.requestLayout();
于 2012-10-25T11:33:51.940 回答