| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML> |
| <HEAD> |
| |
| <meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2005. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." > |
| |
| <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"> |
| <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"> |
| |
| <LINK REL="STYLESHEET" HREF="../book.css" CHARSET="ISO-8859-1" TYPE="text/css"> |
| <TITLE> |
| FormText control |
| </TITLE> |
| </HEAD> |
| <BODY BGCOLOR="#ffffff"> |
| |
| <H1> |
| FormText control</H1> |
| <p align="left">It is possible to achieve highly polished results using images, |
| hyperlinks and text snippets mixed together in a form. However, when the mix of |
| these elements is needed as part of one integral text, it is very hard to do. To |
| remedy the problem, UI Forms offer a rudimentary text control that can do the |
| following:</p> |
| <ul> |
| <li> |
| <p align="left">Render plain wrapped text</p></li> |
| <li> |
| <p align="left">Render plain text but convert any segment that starts with |
| <b>http://</b> into a hyperlink on the flyv</p></li> |
| <li> |
| <p align="left">Render text with XML tags</p></li> |
| </ul> |
| <p align="left">In all the modes, <code>FormText</code> control is capable of |
| rendering either a string or an input stream.</p> |
| <h2 align="left">Rendering normal text (label mode)</h2> |
| <div align="left"> |
| <pre> FormText rtext = toolkit.createFormText(form.getBody(), true); |
| String data = "Here is some plain text for the text to render."; |
| rtext.setText(data, false, false);</pre> |
| </div> |
| <div align="left"> |
| <p align="left">Second argument set to <code>false</code> means that we will |
| treat input text as-is, and the third that we will not try to expand URLs if |
| found.</p></div> |
| <div align="left"> |
| <h2>Automatic conversion of URLs into hyperlinks</h2> |
| <p>It is possible to still handle the text as normal but automatically |
| convert segments with http:// protocol into hyperlinks:</p> |
| <pre> FormText rtext = toolkit.createFormText(form.getBody(), true); |
| String data = "Here is some plain text for the text to render; "+ |
| "this text is at http://www.eclipse.org web site."; |
| rtext.setText(data, false, <b>true</b>);</pre> |
| <p align="left">Similar to the <code>Hyperlink</code> control, <code> |
| FormText</code> accepts listeners that implement <code>HyperlinkListener</code>. |
| These listeners will be notified about events related to the hyperlink |
| segments within the control.</p></div> |
| </BODY> |
| </HTML> |