0

在我的 javafx 应用程序中,我使用的是免费的开源 Java 报告工具DynamicReports 。在按钮事件的代码中,我调用了一种方法来显示报告:

report1.setOnAction(event -> {

                    getSupplierListReport();

                }

        );

这是方法:

public void getSupplierListReport()
    {

        report = DynamicReports.report();


        try {
            //show the report


            report
                    .columns(
                            Columns.reportRowNumberColumn("No"),
                            Columns.column("First Name", "f_name", DataTypes.stringType()),
                            Columns.column("Last Name", "l_name", DataTypes.stringType()),
                            Columns.column("Email", "email", DataTypes.stringType())

                    )
                    .title(//title of the report
                            Components.text("Supplier List Report")
                                    .setHorizontalAlignment(HorizontalAlignment.CENTER).setStyle(boldCenteredStyle))
                    .pageFooter(Components.pageXofY().setStyle(boldCenteredStyle))//show page number on the page footer
                    .highlightDetailEvenRows()
                    .setColumnTitleStyle(columnTitleStyle)
                    .setDataSource("SELECT f_name, l_name, email FROM suppliers", connection)
                    .show();
            //export the report to a pdf file
            report.toPdf(new FileOutputStream("d:/report.pdf"));

        } catch (DRException e) {
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }


    }

该报告正在正确生成并且没有错误。我的想法是,当我关闭主窗口时,报告窗口并没有变冷,这没关系,但每当我关闭报告窗口时,它就会关闭整个应用程序!!!可能会以某种方式触发动态报告工具关闭功能以关闭整个应用程序。如何克服这个问题??

4

1 回答 1

0

似乎如果我在 show 方法中传递参数 false 它不会关闭应用程序。

.show(false);
于 2016-02-24T10:10:18.077 回答