📄 lgpltextdemo.java
字号:
/**
* ========================================
* JFreeReport : a free Java report library
* ========================================
*
* Project Info: http://www.jfree.org/jfreereport/index.html
* Project Lead: Thomas Morgner;
*
* (C) Copyright 2000-2002, by Simba Management Limited and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* -------------------
* LGPLTextDemo.java
* -------------------
* (C)opyright 2002, by Simba Management Limited.
*
* Original Author: David Gilbert (for Simba Management Limited);
* Contributor(s): -;
*
* $Id: LGPLTextDemo.java,v 1.4 2003/11/07 18:33:48 taqua Exp $
*
* Changes
* -------
* 29-Nov-2002 : Version 1 (DG);
*
*/
package org.jfree.report.demo;
import java.awt.BorderLayout;
import java.net.URL;
import java.text.MessageFormat;
import javax.swing.BorderFactory;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import org.jfree.report.Boot;
import org.jfree.report.JFreeReport;
import org.jfree.report.ReportProcessingException;
import org.jfree.report.demo.helper.AbstractDemoFrame;
import org.jfree.report.modules.gui.base.PreviewDialog;
import org.jfree.report.modules.gui.base.components.ActionMenuItem;
import org.jfree.report.modules.parser.base.ReportGenerator;
import org.jfree.report.util.Log;
import org.jfree.ui.RefineryUtilities;
/**
* A simple JFreeReport demonstration. The generated report contains
* the complete text of the LGPL.
*
* @author Thomas Morgner
*/
public class LGPLTextDemo extends AbstractDemoFrame
{
/**
* Constructs the demo application.
*
* @param title the frame title.
*/
public LGPLTextDemo(final String title)
{
setTitle(title);
setJMenuBar(createMenuBar());
setContentPane(createContent());
}
/**
* Creates a menu bar.
*
* @return the menu bar.
*/
private JMenuBar createMenuBar()
{
final JMenuBar mb = new JMenuBar();
final JMenu fileMenu = createJMenuItem("menu.file");
final JMenuItem previewItem = new ActionMenuItem(getPreviewAction());
final JMenuItem exitItem = new ActionMenuItem(getCloseAction());
fileMenu.add(previewItem);
fileMenu.addSeparator();
fileMenu.add(exitItem);
mb.add(fileMenu);
return mb;
}
/**
* Creates the content for the application frame.
*
* @return a panel containing the basic user interface.
*/
private JPanel createContent()
{
final JPanel content = new JPanel(new BorderLayout());
content.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
final JTable table = new JTable();
final JScrollPane scrollPane = new JScrollPane(table);
content.add(scrollPane);
return content;
}
/**
* Displays a print preview screen for the sample report.
*/
protected void attemptPreview()
{
final URL in = getClass().getResource("/org/jfree/report/demo/lgpl.xml");
if (in == null)
{
JOptionPane.showMessageDialog(this,
MessageFormat.format(getResources().getString("report.definitionnotfound"),
new Object[]{in}),
getResources().getString("error"), JOptionPane.ERROR_MESSAGE);
}
final JFreeReport report;
try
{
report = parseReport(in);
report.setData(new DefaultTableModel());
}
catch (Exception ex)
{
showExceptionDialog("report.definitionfailure", ex);
return;
}
try
{
final PreviewDialog frame = new PreviewDialog(report);
frame.getBase().setToolbarFloatable(true);
frame.pack();
RefineryUtilities.positionFrameRandomly(frame);
frame.setVisible(true);
frame.requestFocus();
}
catch (ReportProcessingException pre)
{
showExceptionDialog("report.previewfailure", pre);
}
}
/**
* Reads the report from the specified template file.
*
* @param templateURL the template location.
*
* @return a report.
*/
private JFreeReport parseReport(final URL templateURL)
{
JFreeReport result = null;
final ReportGenerator generator = ReportGenerator.getInstance();
try
{
result = generator.parseReport(templateURL);
}
catch (Exception e)
{
Log.error("Failed to parses", e);
}
return result;
}
/**
* Entry point for running the demo application...
*
* @param args ignored.
*/
public static void main(final String[] args)
{
// initialize JFreeReport
Boot.start();
final LGPLTextDemo frame = new LGPLTextDemo("LGPL text Demo");
frame.pack();
RefineryUtilities.centerFrameOnScreen(frame);
frame.setVisible(true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -