a multiline display of text on the screen. Sometimes you permit the user to edit it. You can control where the line breaks are by embedding '\n' characters in your text. The AWT (Advanced Windowing Toolkit) equivalent is called a TextArea. AWT TextArea has an advantage over JTextArea.
Without any coding, with AWT, the user can select, copy and paste, even in an unsigned Applet. However, Applets must be signed for copy/paste to work in Swing. Copy/paste works in Swing without signing for applications.
JTextAreas have use the same font size and colours throughout. If you want to vary them, you will need a JTextPane or a JTextEditorPane.
For a complex display, consider generating a page of HTML (Hypertext Markup Language), XHTML (extensible Hypertext Markup Language) or XML (extensible Markup Language) on the fly, then rendering it, perhaps in an iframe, in a separate browser window, or a separate browser task. Then you can use elaborate CSS (Cascading Style Sheets) style sheets, rowspan and colspan tables. Verifying generated HTML is a snap.
By default JTextArea will not automatically wrap text. You must embed '\n' charactercs in your text where you want the line breaks. To get automatic line wrapping, you need two calls: JTextArea.setLineWrap( true ) and JTextArea.setWrapStyleWord( true ).
|
|
You can get the freshest copy of this page from: | or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror) |
| http://mindprod.com/jgloss/jtextarea.html | J:\mindprod\jgloss\jtextarea.html | |
![]() | ||
| Canadian Mind Products | ||
| mindprod.com IP:[65.110.21.43] | ||
| view Blog | Your face IP:[38.107.179.212] | |
| Feedback | You are visitor number 27,542. | |