2012-10-30 67 views
0

我有2000个数据。我想在运行时将数据绑定到javafx 2.2中的选择框。当我绑定数据到选择框然后它的显示javafx 2.2中choicebox的容量是多少?

java.lang.RuntimeException:java.lang.reflect.InvocationTargetException 

异常和我的申请被绞死。请给我一些建议。

+0

这实际上可能是任何问题,您将需要显示一些代码重现它。这是唯一引发的异常还是嵌套的异常呢? –

回答

0

相同的绑定是否适用于较小的一组数据?

下一段代码适用于我。虽然Popup在第一次出现之前有1-2秒的延迟。

public class DoHugeChoiceBox extends Application { 
    @Override 
    public void start(Stage stage) { 
     ObservableList<String> list = FXCollections.<String>observableArrayList(); 
     for (int i = 0; i < 2000; i++) { 
      list.add("item " + i); 
     } 
     ChoiceBox cb = new ChoiceBox(list); 
     cb.getSelectionModel().select(1000); 

     HBox g = HBoxBuilder.create().children(cb).build(); 
     stage.titleProperty().bind(cb.valueProperty()); 

     stage.setScene(new Scene(g)); 
     stage.setHeight(100); 
     stage.setWidth(200); 
     stage.show(); 
    } 

    public static void main(String[] args) { launch(); } 
}