Jump to content
JasperReports Library 7.0 is now available ×

PrintWhenExpression (noXmlDesign) for fields


2005 IR Help

Recommended Posts

By: rumbuff - rumbuff

PrintWhenExpression (noXmlDesign) for fields

2004-07-08 06:06

Hi all,

 

first of all, I'd like to thank Teodor for his great work!

 

Now my question:

I compile dynamicly (noXmlDesign) and would like to change the background of fields if a certain condition is true.

 

How to do this? I'm using version 0.5.3.

 

Here is my code:

 

for (int i = 0; i < table.getModel().getColumnCount(); i++)

{

String colName = table.getModel().getColumnName(i);

JRDesignStaticText header = new JRDesignStaticText();

JRDesignTextField detail = new JRDesignTextField();

 

if(i == 0)

{

header.setX(0);

detail.setX(0);

}

else

{

header.setX(defaultWidth * i + defaultMargin);

detail.setX(defaultWidth * i + defaultMargin);

}

 

header.setY(5);

header.setWidth(defaultWidth);

header.setHeight(15);

header.setForecolor(Color.white);

header.setBackcolor(new Color(0x33, 0x33, 0x33));

header.setMode(JRElement.MODE_OPAQUE);

header.setTextAlignment(JRTextElement.TEXT_ALIGN_LEFT);

header.setFont(getFontBold());

header.setText(colName);

hf.addElement(header);

 

detail.setY(4);

detail.setWidth(defaultWidth);

detail.setHeight(15);

detail.setTextAlignment(JRTextElement.TEXT_ALIGN_LEFT);

detail.setFont(getFontNormal());

 

JRDesignExpression expression = new JRDesignExpression();

expression.setValueClass(java.lang.String.class);

expression.setText("$F{" + colName + "}");

detail.setExpression(expression);

 

detail.addElement(detail);

 

// Fields

JRDesignField field = new JRDesignField();

field.setName(colName);

field.setValueClass(java.lang.String.class);

design.addField(field);

}

 

design.setDetail(detail);

 

~~~~~~

 

Thanks a lot !!

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...