🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: ibm.software.vajava.beans
Article #14

Re: JTextField in VCE

#14
From: Eric Rizzo
Date: Fri, 12 Apr 2002 14:08
37 lines
3185 bytes
Daniel Faensen wrote:

> How do I synchronize String properties of my model bean (e.g., the Name of a
> Customer) with the contents of a JTextField most elegantly. I prefer to work
> with the VAJ Visual Composision Editor.
> 
> I tried to tear off the document property of JTextField and connect its
> document event to the Customer's Name property. The value of this connection
> I connected to the text property of the JTextField.
> While this perfectly updates the Customer Name changing the Name is not
> reflected in the JTextField.


One way to make it work is to give your Customer bean understanding 
about Documents.  If it has a nameModel property (an instance of 
Document) and it's setName() and getName() just delegate to that, you 
can link the Document of the text field and the Customer's Document up 
directly (ie, they share one Document instance).  For non-Document-aware 
classes to see the changes to name you'll have to make sure the name 
property (not actually an instance of String) is bound (fires 
PropertyChangeEvents when it changes) and that the Customer takes 
DocumentEvents and fires PropertyChangeEvents as a result.  Also, 
converting between String and Document is not intuitive.  Of course, 
your Customer object now is coupled to a Swing class (Document), which 
isn't ideal.
Incidentally, we have Swing's brain-dead designers to thank for the 
mess.  Far too few of the Swing classes are beans or bean-aware as they 
should be, and whomever designed the Document interface should be pulled 
form their ivory tower and flogged.

HTH,
	Eric
-- 
Eric Rizzo
--------------
VisualAge for Java Frequently Asked Questions (FAQ)
at http://www.jguru.com/faq/VAJ
Technical Details
Message-ID: <3CB6EA47.8040009@jibeinc.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!supernews.com!peer1-sjc1.usenetserver.com!usenetserver.com!hub1.nntpserver.com!telocity-west!TELOCITY!203.109.225.2!nntp-relay.ihug.net!ihug.co.nz!newsfeed.media.kyoto-u.ac.jp!newsfeed01.sul.t-online.de!t-online.de!news.software.ibm.com!not-for-mail
References: <a96e56$1era$1@news.boulder.ibm.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fed75,6cd90e39f400a0fd
X-Google-Attributes: gidfed75,public
X-Google-Thread: 114aa0,6cd90e39f400a0fd
X-Google-Attributes: gid114aa0,public
X-Google-Thread: 109b1c,6cd90e39f400a0fd
X-Google-Attributes: gid109b1c,public
X-Google-ArrivalTime: 2002-04-12 07:20:54 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!supernews.com!peer1-sjc1.usenetserver.com!usenetserver.com!hub1.nntpserver.com!telocity-west!TELOCITY!203.109.225.2!nntp-relay.ihug.net!ihug.co.nz!newsfeed.media.kyoto-u.ac.jp!newsfeed01.sul.t-online.de!t-online.de!news.software.ibm.com!not-for-mail
From: Eric Rizzo <eric.rizzo@jibeinc.com>
Newsgroups: ibm.software.vajava.beans,ibm.software.vajava.ide,ibm.software.vajava.language
Subject: Re: JTextField in VCE
Date: Fri, 12 Apr 2002 10:08:07 -0400
Organization: Disorganized
Lines: 38
Message-ID: <3CB6EA47.8040009@jibeinc.com>
References: <a96e56$1era$1@news.boulder.ibm.com>
NNTP-Posting-Host: bdsl.66.12.253.82.gte.net
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.boulder.ibm.com 1018620375 23408 66.12.253.82 (12 Apr 2002 14:06:15 GMT)
X-Complaints-To: mattgar@us.ibm.com, tlew@us.ibm.com
NNTP-Posting-Date: 12 Apr 2002 14:06:15 GMT
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4) Gecko/20011128 Netscape6/6.2.1
X-Accept-Language: en-us