RCP应用程序中的JavaFX AreaChat图

时间:2016-06-01 12:16:54

标签: javafx rcp

我是JavaFX / RCP的新手,并尝试在RCP应用程序中执行一个示例JavaFX图。它显示空对话,没有图表。任何人都可以帮我确定问题吗?

    @Execute
    public void execute(final Shell shell) {

    if ( shlInfrastructureReport != null && !shlInfrastructureReport.isDisposed()){

        shlInfrastructureReport.close();
    }

    shlInfrastructureReport = new Shell(shell.getDisplay());
    final FXCanvas fxCanvas = new FXCanvas(shlInfrastructureReport, SWT.NONE);
    Group group = new Group();
    Scene scene = new Scene(group);

    final NumberAxis xAxis = new NumberAxis(1, 31, 1);
    final NumberAxis yAxis = new NumberAxis();
    final AreaChart<Number,Number> areaChat = new AreaChart<Number,Number>(xAxis,yAxis);
    areaChat.setTitle("Sample Report");

    XYChart.Series series= new XYChart.Series();
    series.setName("Sample");
    series.getData().add(new XYChart.Data(1, 4));
    series.getData().add(new XYChart.Data(3, 10));
    series.getData().add(new XYChart.Data(6, 15));
    series.getData().add(new XYChart.Data(9, 8));
    series.getData().add(new XYChart.Data(12, 5));
    series.getData().add(new XYChart.Data(15, 18));
    series.getData().add(new XYChart.Data(18, 15));
    series.getData().add(new XYChart.Data(21, 13));
    series.getData().add(new XYChart.Data(24, 19));
    series.getData().add(new XYChart.Data(27, 21));
    series.getData().add(new XYChart.Data(30, 21));

    areaChat.getData().addAll(series);
    group.getChildren().add(areaChat);
    fxCanvas.setScene(scene);

1 个答案:

答案 0 :(得分:0)

谢谢,它得到了解决方案。问题是我错过了设置布局。

    final RowLayout layout = new RowLayout();
    shlInfrastructureReport.setLayout(layout);