J2ME Polish
J2ME Polish 2.4 Documentation
Enough Software

html Text-Effect

The html text-effect allows you to design complex text.


the html text-effect
The above text has been realized with this Java code:

//#style aboutText
form.append("<span class=\"aboutHeader\">FileExplorer</span> is a sample application of <b>J2ME Polish.</b> " 
		+ "You can use and modify this application for your own purposes - the sources are provided in "
		+ "J2ME Polish:\n<span class=\"aboutLink\">www.j2mepolish.org</span>");

In the polish.css file following design has been specified:

.aboutText {
	text-effect: html;
	font-color: #333;
	layout: bottom;

.aboutHeader {
	always-include: true;
	font-size: large;
	font-style: bold;
	font-color: #933;

.aboutLink {
	always-include: true;
	font-style: underlined | italic;
	font-color: #444;

Following HTML constructs are supported in this text-effect:

  • <b>: makes your text bold.
  • <i>: makes your text italic.
  • <style>: allows you to specify inline styles that automatically inherit from the outside style, for example: <div style="color: red; font-style: underlined; background-color: silver;">Hello World</div>
  • <img>: adds a local image: <img src="/smile.png"/>
  • <a>: adds an external link, for that to work you need to programmatically set your MIDlet: de.enough.polish.ui.texteffects.HtmlTextEffect.setMidlet(MIDlet midlet, Command cmdOpenWebsite, Command cmdOpenMailto, Command cmdCall);
  • <any class="styleName">: uses the specified style for the text. Note that you need to define the always-include: true; within the referenced style, otherwise the style will be optimized away.

If you are using class styles within your text you can use any design settings in those style, including other text effects. See StringItems for more details.

You can add your own tag parsing library by implementing HtmlTextEffect.HtmlTextParser and calling HtmlTextEffect.setGlobalParser(HtmlTextParser parser).



back to top