Jump to content

Why i cant set forecolor and backcolor of element?


goompas

Recommended Posts

Hello

Why i cant set forecolor and backcolor of element after filling ?

                        page = (JRPrintPage) pages.get(i);
                       elements = page.getElements();

 

List modifiedElements = new ArrayList();

 if (element instanceof JRPrintText)
                                {

                                    JRPrintText modifiedElement = ((JRPrintText) element);

                                    modifiedElement.setForecolor(Color.BLUE);

                                    modifiedElements.add(modifiedElement);

}

 page.setElements(modifiedElements);

 

Why this dont work? What should i do?

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

The JRPrintText objects that result from a report fill do not implement these methods as they are optimized to store attributes common to other elements in shared objects.  The objects should probably throw exceptions on unimplemented methods so that it's clear that this is not supported.

If you want to perform this kind of processing on filled reports, a trick that helps is to go through an XML export in order to lose the fill optimizations.  So do an JasperExportManager.exportReportToXml() and then read back the JasperPrint object from the XML export via JRPrintXmlLoader, and then process this object.  Note that this will result in an increase of heap space required by the filled report.

Regards,

Lucian

Link to comment
Share on other sites

Thanks for answer

Is there any way to change dynamicly color of textfield element to any rgb? I know that can use styled text, but then numbers fields i must declare as string and when export to xls, excel dont see this numbers as numbers but strings.

Link to comment
Share on other sites

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...