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!

Jfreereport help

843805Feb 10 2006
hi ,
I am generating a report using JFreeReport.
I can view the report,but i need to append values in the report.
Ex:
the report shows like this
[column 0 values]
[column 1 values]
[column 2 values]
where column values are got from the table model.

I am using class TextFieldElementFactory
to populate values in itemband.
here is the code
  TextFieldElementFactory factory = new TextFieldElementFactory();
                        factory.setName("T1");
	    factory.setAbsolutePosition(new Point2D.Float(0, 10));
	    factory.setMinimumSize(new FloatDimension(150, 12));
	    factory.setColor(Color.black);
	    factory.setHorizontalAlignment(ElementAlignment.LEFT);
	    factory.setVerticalAlignment(ElementAlignment.MIDDLE);
	    factory.setNullString("-");
	    factory.setFieldname(model.getColumnName(0));
	    factory.setFontSize(10);
	    report.getItemBand().addElement(factory.createElement());
	       	    	    
	    factory = new TextFieldElementFactory();
	    factory.setName("T2");
	    factory.setAbsolutePosition(new Point2D.Float(20,10 ));
	    factory.setMinimumSize(new FloatDimension(150, 12));
	    factory.setDynamicHeight(true);
	    factory.setColor(Color.black);
	    factory.setHorizontalAlignment(ElementAlignment.LEFT);
	    factory.setVerticalAlignment(ElementAlignment.MIDDLE);
	    factory.setNullString("-");
	    factory.setFieldname(model.getColumnName(1));
	    report.getItemBand().addElement(factory.createElement());
	    System.out.println(factory.getFieldname());
	    
	    
	    factory = new TextFieldElementFactory();
	    factory.setName("T3");
	    factory.setAbsolutePosition(new Point2D.Float(10,70));
	    factory.setMinimumSize(new FloatDimension(150, 12));
	    factory.setColor(Color.black);
	    factory.setHorizontalAlignment(ElementAlignment.LEFT);
	    factory.setVerticalAlignment(ElementAlignment.MIDDLE);
	    factory.setNullString("-");
	    factory.setFieldname(model.getColumnName(2));
	    report.getItemBand().addElement(factory.createElement());
where model is TableModel.

what i want is,i need to append the column name with the column value like
Id [column1 value]
name [column2 value]
phone [column3 value]
1) what method i must use to prefix column name with the column value's.
2) note that i want the values to be printed in columnar format (ie.,
Columnname1 value
columnname2 value

not as

columnname1 columnname2
value value
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 10 2006
Added on Feb 10 2006
0 comments
85 views