[4725] in java-interest

home help back first fref pref prev next nref lref last post

Re: Numeric TextFields

daemon@ATHENA.MIT.EDU (Patrick Taylor)
Thu Jan 11 16:26:39 1996

Date: Thu, 11 Jan 1996 13:29:58 -0500
From: Patrick Taylor <patrick.taylor@template.com>
To: java-interest@java.sun.com
In-Reply-To: <199601110212.SAA14577@java.sun.com>


> From: Sami.Shaio@Eng.Sun.COM (Sami Shaio)
> Date: Wed, 10 Jan 1996 11:58:15 -0800
> Subject: Numeric TextFields
> 
> Apologies for the wide distribution. I thought that I'd post an example
> of how to do a subclass of an awt textfield that only accepts numeric
> input. So here it is. It's got some bugs (like not all number formats
> are recognized) but it basically works otherwise. Use it in good health.
> ...
>  * Works by overriding the handleEvent method and only allowing
>  * certain events to trickles down to the textfield peer.
>  * The event model is that the component and its parents get
>  * to see an event before the peer does. If both the component
>  * and all the parents return false then the event passes on
>  * to the peer. The event may also be modified (i.e. changing
>  * the value of the key for example).

Did the event model change between beta1 and beta2?  I've got beta2 at
home, but I've still only got beta1 at work where I'm looking at this.
Looking at the beta1 Component postEvent source, it appears that the event
is first given to the peer, and only passed onto the component if the peer
returns false.  Unfortunately, this means that your NumericTextField class
doesn't work with beta1, since it is unable to prevent the peer from taking
non-numeric keys (i.e., I can enter letters into the field).  It does seem
like the beta1 model is pretty limited, but the model you describe inverts
the peer/component relationship, and is thus more powerful.
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post