🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: JTextField missing events

#10582
From: Ernesto Bascón Pantoja
Date: Fri, 27 Aug 1999 00:00
40 lines
1964 bytes

"Norman H. Samuelson" wrote:

> I seem to be having trouble with some missing events using JTextField.  I
> want to be notified whenever ANY key is typed in the field, including
> ordinary text or delete or backspace.  I get an event when the user hits the
> ENTER key, and on Backspace, but not on Delete (or maybe I have those two
> switched).
>
> What I want is to know that something has changed, so I can set a flag, then
> when the user types ENTER or TAB or clicks on some other field, I want to
> check that his input is valid.  This seems to work well with TextField, but
> not with JTextField.
>
> I have tried a few ways of trying to catch all these keystrokes, but nothing
> is working yet.  Any help would be appreciated.
>
> - Norm -

Hi:

I've worked with KeyEvents and MouseEvents using JTextField and they work
perfectly. Here is the code I use:

void keyPressed(KeyEvent e)
  {
   int k = e.getKeyCode();

    switch (k)
    {
     case KeyEvent.VK_DELETE: //Delete code here
                                                    reset();
                                                    e.setKeyCode(0);
                                                    return;
     case KeyEvent.VK_ENTER:  //Enter pressed
                                                   return;
     case KeyEvent.VK_UP:        //up-arrow
    }
}
Technical Details
Message-ID: <37C70C94.84A11937@estudiantes.ucbcba.edu.bo>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7q6ljs$rlr10@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,73efcbe5a6a17ec6
X-Google-Attributes: gid111d45,public
From: Ernesto Bascón Pantoja  <bascone@estudiantes.ucbcba.edu.bo>
Subject: Re: JTextField missing events
Date: 1999/08/27
Message-ID: <37C70C94.84A11937@estudiantes.ucbcba.edu.bo>
X-Deja-AN: 517993028
Content-Transfer-Encoding: 7bit
References: <7q6ljs$rlr10@forums.borland.com>
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
Organization: UCB
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing