goompas Posted June 26, 2009 Share Posted June 26, 2009 HelloI have question about dynamic setting colors . Is there possible that textfield or any other element have dynamic color? I dont think about conditional styles. I have object that have fields value and color.MyObject:Double value;Color color; Now i wanna attach field color to property backcolor or forecolor of textfield. Is this possible? I know that i can make conditional style using filed color, but what when color is any rgb combination?I see that JasperReport not allow set color using variables or fields, only string.I can make this expression in conditional style$F{bean}.getColor().equals("red") then in this conditional style set color to red, but what i should do when color is any rgb combination? Link to comment Share on other sites More sharing options...
lucianc Posted June 29, 2009 Share Posted June 29, 2009 Such dynamic styling is not currently supported in JasperReports.Regards,Lucian Link to comment Share on other sites More sharing options...
niik Posted June 29, 2009 Share Posted June 29, 2009 This is possible by modifying the background or foreground color of a report style after filling the report:jasperPrint = JasperFillManager.fillReport(rptfile,parameters,ds);Color userColor = new Color(R, G, B);JRStyle[] styleList = jasperPrint.getStyles();for (int j = 0; j < styleList.length; j++) { if (styleList[j].getName().equals("tableHeader")) { styleList[j].setBackcolor(userColor); jasperPrint.addStyle(styleList[j], true); } else if (styleList[j].getName().equals("formTitle")) { styleList[j].setForecolor(userColor); jasperPrint.addStyle(styleList[j], true); }}Let me know if you have any questions. Link to comment Share on other sites More sharing options...
goompas Posted June 30, 2009 Author Share Posted June 30, 2009 Thanks niik for answerI think that is good idea and try it. Link to comment Share on other sites More sharing options...
Teodor Danciu Posted July 7, 2009 Share Posted July 7, 2009 Hi, Coloring text dynamically can also be achieved using styled text or markup.Check the /demo/samples/markup sample or even the older one in /demo/samples/styledtext. I hope this helps.Teodor Link to comment Share on other sites More sharing options...
shanmei Posted March 4, 2010 Share Posted March 4, 2010 Hi, What is the full location to "/demo/samples/markup" and "/demo/samples/styledtext"? thanks,Shanmei Link to comment Share on other sites More sharing options...
shibinthomas Posted March 4, 2010 Share Posted March 4, 2010 U need to download the jasperreports .For example for version 3.5.2 u will found in this location -> jasperreports-3.5.2\demo\sampleslink http://sourceforge.net/projects/jasperreports/files/jasperreportsRegardsShibin Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now