简体   繁体   中英

Change StaticText background color dynamically with JasperReports API

I would like to change the background color of Static text programmatically, nothing happened, but setForecolor is working (change the font color).

for example:

JRDesignStaticText _StaticText = new JRDesignStaticText();
// setForecolor is working
_StaticText.setForecolor(java.awt.Color.green);
//but setBackcolor not working
_StaticText.setBackcolor(java.awt.Color.red);

The background color is applied when the element is opaque. So you need to also do

_StaticText.setMode(ModeEnum.OPAQUE);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM