🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #9081

Re: Jtextfield problem

#9081
From: sven goetgeluck
Date: Tue, 23 May 2000 00:00
54 lines
2499 bytes
John ,
this downt work always crashes when at firePropertyChange
what al i doing wrong???

"John P. McGrath" wrote:

> On Fri, 19 May 2000 17:42:25 +0200, Sven Goetgeluck wrote:
>
> > Yes this is what i mean but don't kno to implement it in the
> > source, can you help?
>
> Here is one way you could do it:
>
>     public class PlusMinusTextField
>         extends JPanel
>     {
>         private JTextField textField;
>         private String text;
>         public static final String TEXT_PROPERTY = "text";
>             :
>             :
>         jbInit() {
>             :
>             textField = new JTextField();
>             lastText = "";
>             Document document = textField.getDocument();
>             document.addDocumentListener( new DocumentListener() {
>                 private void fireChange() {
>                     String oldText = text;
>                     text = textField.getText();
>                     firePropertyChange( TEXT_PROPERTY, oldText, text );
>                 }
>                 public void changedUpdate( DocumentEvent event ) {
>                     fireChange();
>                 }
>                 public void insertUpdate( DocumentEvent event ) {
>                     fireChange();
>                 }
>                 public void removeUpdate( DocumentEvent event ) {
>                     fireChange();
>                 }
>             } );
>         }
>     }
>
> Just one note:  If the "value" of your PlusMinusTextField is always
> supposed to be numeric, you will probably want to enforce that in the
> Document, and then rather than fire a "text" property, you could fire an
> "intValue" property instead.
>
> --
> John P. McGrath
> <JPMcGrath@fast.net>
> <jpm@nscs.fast.net>
Technical Details
Message-ID: <392A7C85.7D72C823@officeline.be>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <3921af12@dnews> <39230C94.3B09A3A0@home.com> <39242302@dnews> <MPG.138e6cabc7cff616989936@forums.borland.com> <39250aa2@dnews> <MPG.139148a8c31034b098993c@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,e3d8a7969574fa02
X-Google-Attributes: gid111d45,public
From: sven goetgeluck <sven@officeline.be>
Subject: Re: Jtextfield problem
Date: 2000/05/23
Message-ID: <392A7C85.7D72C823@officeline.be>
X-Deja-AN: 626260691
Content-Transfer-Encoding: 7bit
References: <3921af12@dnews> <39230C94.3B09A3A0@home.com> <39242302@dnews> <MPG.138e6cabc7cff616989936@forums.borland.com> <39250aa2@dnews> <MPG.139148a8c31034b098993c@forums.borland.com>
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
X-Trace: 23 May 2000 05:32:12 -0800, 194.7.164.231
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing