Article View: comp.lang.java.gui
Article #84Re: A very humble Java GUI question
From: Bill Tschumy
Date: Thu, 22 Mar 2001 03:01
Date: Thu, 22 Mar 2001 03:01
50 lines
3199 bytes
3199 bytes
On Wed, 21 Mar 2001 18:22:58 -0600, Paul King wrote
(in message <rihibt42piiu8mbei09uc7o066ll4sramp@4ax.com>):
> I am not necessarily new to Java, but am a novice at writing GUI-based
> Java programs.
>
> I am trying to build a GUI with a text object (JTextPane). I have a need
> to place display text into that object. Here is the declaration:
>
> javax.swing.JTextPane txtMessage = new javax.swing.JTextPane();
>
> Having done that, in the same scope as the current object that the above
> declaration was in, I placed this statement in one of the methods, a
> response to pressing a button:
>
> txtMessage.text = "Some text";
>
> hoping it would appear as displayed text in the text pane. The logic of
> using txtMessage.text is that the "text" part appears as a property on my
> CodeWarrior object inspector for the "txtMessage" object. Giving the
> "text" property a value in the object inspector results in that value
> being displayed.
>
> 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. So, where
> is the Object inspector assigning the value? In object inspectors of other
> languages I've written in, the properties listed there are properties of
> the class that is "inspected". Usually, a simple assignment statement like
> the one above should work. However, it does not compile, because "text" is
> apparently not a property of JTextPane. Is CodeWarrior trying to screw
> with my mind?
>
> If I am going about this all wrong, can anyone suggest how I can write
> text into a GUI-based text object?
>
> Thanks for any help you can offer.
>
> PJK
I don't have any advice about why CodeWarrior is showing that
property, but to set the text displayed you should do a
txtMessage.setText("Some Text");
--
Bill Tschumy
Otherwise -- Austin, TX
bill@otherwise.com
Technical Details
Message-ID:
<01HW.B6DEC73B002ECDD50931E400@news.jump.net>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!newsxfer.eecs.umich.edu!news.cc.utah.edu!newsfeed.cs.utexas.edu!galaxy.us.dell.com!news-feeds.jump.net!news.jump.net!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-21 19:04:19 PST Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!newsxfer.eecs.umich.edu!news.cc.utah.edu!newsfeed.cs.utexas.edu!galaxy.us.dell.com!news-feeds.jump.net!news.jump.net!not-for-mail From: Bill Tschumy <bill@otherwise.com> Newsgroups: comp.lang.java.gui,codewarrior.windows Subject: Re: A very humble Java GUI question Date: Wed, 21 Mar 2001 21:01:47 -0600 Organization: Otherwise Lines: 51 Message-ID: <01HW.B6DEC73B002ECDD50931E400@news.jump.net> References: <rihibt42piiu8mbei09uc7o066ll4sramp@4ax.com> NNTP-Posting-Host: otherwise.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.jump.net 985230093 19528 207.8.48.9 (22 Mar 2001 03:01:33 GMT) X-Complaints-To: abuse@jump.net NNTP-Posting-Date: Thu, 22 Mar 2001 03:01:33 +0000 (UTC) User-Agent: Hogwasher/2.6.1 (Macintosh)