Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

JFreeReport(By using Table Model)

843805Feb 6 2006 — edited Feb 8 2006
Hi,

Good Evening

I got the sample coding for JFreeReport from
jfreereport-0.8.3-A4.pdf.I understand the coding.

But I couldnot understand What are the required libraries and how to add all in to my program.I didnot know how do set 'jfreereport-0.8.3.jar' file to my classpath. I couldnot understand it from the above pdf.So I got so many errors of "cannot find symbol".

I unzip all the contents of jfreereport-0.8.3 and put in to a directory Jfree.
And in C:\java\jdk1.5.0-05\bin I write the coding for HelloWorld.java
My coding is
import java.awt.*;
import javax.swing.table.*;


public class HelloWorld
{
public HelloWorld()
{

TableModel data = createData();
JFreeReport report = createReportDefinition();
report.setData(data);
try
{
PreviewFrame preview = new PreviewFrame(report);
preview.pack();
preview.setVisible(true);
}
catch (ReportProcessingException e)
{
Log.error("Failed to generate report ", e);
}

}

private TableModel createData()
{

Object[] columnNames = new String[] { "Column1", "Column2" };
DefaultTableModel result = new DefaultTableModel(columnNames, 1);
result.setValueAt("Hello", 0, 0);
result.setValueAt("World!", 0, 1);
return result;

}

private JFreeReport createReportDefinition()
{

JFreeReport report = new JFreeReport();
report.setName("A Very Simple Report");

TextElement t1 = ItemFactory.createStringElement(
"T1",
new Rectangle2D.Double(0.0, 0.0, 150.0, 20.0),
Color.black,
ElementAlignment.LEFT.getOldAlignment(),
ElementAlignment.MIDDLE.getOldAlignment(),
null, // font
"-", // null string
"Column1"
);

report.getItemBand().addElement(t1);

TextElement t2 = ItemFactory.createStringElement(
"T2",
new Rectangle2D.Double(200.0, 0.0, 150.0, 20.0),
Color.black,
ElementAlignment.LEFT.getOldAlignment(),
ElementAlignment.MIDDLE.getOldAlignment(),
null, // font
"-", // null string
"Column2"
);

report.getItemBand().addElement(t2);
return report;

}

public static void main(String[] args)
{
HelloWorld app = new HelloWorld();
}

}


So Please help me how can I set classpath,where and how can I add the needed libraries to my program.
Thank you so much,
Meena.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 8 2006
Added on Feb 6 2006
8 comments
364 views