Article View: comp.lang.java.gui
Article #86Re: A very humble Java GUI question
From: gbp
Date: Fri, 23 Mar 2001 06:29
Date: Fri, 23 Mar 2001 06:29
40 lines
2446 bytes
2446 bytes
>However, expressing the object as I have above results in
CodeWarrior
>telling me that the property "text" does not exist as a part of
>javax.swing.JTextPane. Indeed, it does not appear to appear in the
API for
>JTextPane nor any of the classes it implements that I have seen.
Wow did you IDE lie to you! Don't feel bad mine lies too.
There is some decent material on the Text objects at
www.javasoft.com.
I'll give you the summary:
* Java's text objects are a pain to use (you won't find that at
Sun's site) but are powerfull.
* The larger text objects store their text in a Document object.
You can get the Document object by using JTextPane.getDocument()
* This is the key THE BEST WAY TO CHANGE THE TEXT IS BY USING THE
DOCUMENT OBJECT NOT THE setText method. setText is slow and doesn't
draw nicely on the screen.
* The Document object is kinda a pain too!
* Use the document's insertString method.
* so....
myJPane.getDocument.insertString("my stuff", offset, null);
the first argument is a string. the second is the index (you can
get this for other methods of Document) The last argument is the
Attibute you want the text in (null seems to work just fine!);
Neat Trick:
You can tie one Document object to as many Swing Text Components as
you want (or zero if you want).
Technical Details
Message-ID:
<_2Cu6.270115$v.30431734@typhoon.nyroc.rr.com>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!newsfeed.skycache.com!Cidera!cyclone-0.nyroc.rr.com!cyclone-out.nyroc.rr.com!typhoon.nyroc.rr.com.POSTED!not-for-mailReferences:
<rihibt42piiu8mbei09uc7o066ll4sramp@4ax.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10fd6d,e3664f8ad80898dd X-Google-Attributes: gid10fd6d,public X-Google-Thread: fd047,e3664f8ad80898dd X-Google-Attributes: gidfd047,public X-Google-ArrivalTime: 2001-03-22 22:36:06 PST Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!newsfeed.skycache.com!Cidera!cyclone-0.nyroc.rr.com!cyclone-out.nyroc.rr.com!typhoon.nyroc.rr.com.POSTED!not-for-mail From: "gbp" <gpepice1@nycap.rr.com> Newsgroups: comp.lang.java.gui,codewarrior.windows References: <rihibt42piiu8mbei09uc7o066ll4sramp@4ax.com> Subject: Re: A very humble Java GUI question Lines: 44 X-Newsreader: Microsoft Outlook Express 4.72.3612.1700 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3612.1700 Message-ID: <_2Cu6.270115$v.30431734@typhoon.nyroc.rr.com> Date: Fri, 23 Mar 2001 06:29:14 GMT NNTP-Posting-Host: 24.29.62.17 X-Complaints-To: abuse@nycap.rr.com X-Trace: typhoon.nyroc.rr.com 985328954 24.29.62.17 (Fri, 23 Mar 2001 01:29:14 EST) NNTP-Posting-Date: Fri, 23 Mar 2001 01:29:14 EST Organization: Time Warner Road Runner - Albany NY