如何在JFrame上使用DynamicReports显示报表?

时间:2014-03-10 09:17:19

标签: jframe show dynamic-reports

我想在Report上显示JFrame而不使用show()方法。

我不想拥有此弹出框架,我只想在JFrame上看到它。

目前的情况如下:

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         

    JasperReportBuilder jrb = new JasperReportBuilder();         

    int iFontsizeStringI = (Integer) jSpinner1.getValue();
    int iFontsizeStringII= (Integer) jSpinner2.getValue();

    String sPageSize =(String)jComboBox1.getSelectedItem();
    String sPageOrientation = (String)jComboBox2.getSelectedItem();

    String one = jTextField1.getText();
    String two = jTextField2.getText();

    FontBuilder fontI = stl.font("Courier New", true, false, iFontsizeStringI);        
    FontBuilder fontII = stl.font("Courier New", true, false, iFontsizeStringII);

    if(sPageOrientation.equalsIgnoreCase("Landscape") && sPageSize.equalsIgnoreCase("A4"))
        jrb.setPageFormat(PageType.A4, PageOrientation.LANDSCAPE);
    if(sPageOrientation.equalsIgnoreCase("Landscape") && sPageSize.equalsIgnoreCase("A3"))
        jrb.setPageFormat(PageType.A3, PageOrientation.LANDSCAPE);
    if(sPageOrientation.equalsIgnoreCase("Portrait") && sPageSize.equalsIgnoreCase("A3"))
        jrb.setPageFormat(PageType.A3, PageOrientation.PORTRAIT);

    jrb.title(cmp.verticalList(cmp.text(one).setStyle(stl.style().setBorder(stl.penDouble()).setFont(fontI)
            .setHorizontalAlignment(HorizontalAlignment.CENTER)),cmp.text(two).setStyle(stl.style()
            .setFont(fontII).setHorizontalAlignment(HorizontalAlignment.CENTER).setBorder(stl.penDouble()))));
    try {
        jrb.show(false);
    } catch (DRException ex) {
        Exceptions.printStackTrace(ex);
    }
}

我需要更改哪些内容才能让我在JFrame中显示此内容?什么时候没有任何jrxml文件?

1 个答案:

答案 0 :(得分:0)

JFrame frame = new JFrame("Report");
frame.getContentPane().add(new JRViewer(jrb.toJasperPrint()));
frame.pack();
frame.setVisible(true);