🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #18905

Re: textValueChanged event

#18905
From: Dean Henkel
Date: Fri, 03 Apr 1998 00:00
49 lines
2253 bytes
James V. Reagan wrote:

> I'm pulling my hair out on this one, so any help or advice would
> be greatly appreciate.
>
> I am trying to detect when a user types text into a java.awt.TextField
> component.  Using the designer, I'm able to get JBuilder to create
> an adapter class and register it as a TextListener.  However, I put
> a breakpoint in the textValueChanged() function of the generated class,
> and it never gets called.
>
> Anyone have any trouble (or, better yet, any workaround) detecting
> text changing in a text field?
>
> --
> James V. Reagan                Sun Certified Java Programmer
> Principal Consultant           JPartners, Inc.
> mailto:jreagan@jpartners.com   http://www.jpartners.com
> Java & OOA/D Consulting, Mentoring, and Development

  I guess I'd try doing a System.out.println("Got here") to make sure your
not being fooled by the debugger.  \\

I just tried this today and mine worked fine.

Anyhow, textValueChanged did't do what I wanted. I thought that this event
was triggered when the user pressed the Enter key or the Text Component
lost focus, thus you would only get the event upon completion. To my
dismay, I was getting the event on every keypress.

I switched to

JTextField inputField  = new JTextField();

 inputField.addKeyListener(new KeyAdapter() {
         public void keyPressed(KeyEvent evt){
  int keyCode = evt.getKeyCode();
  if(keyCode == KeyEvent.VK_ENTER)
  {  ....Do my thing}

and everything works fine.

This should work for AWT controls as well.  I'm using swing's JTextField
and it appears textValueChanged isn't supported in JTextField. You might
want to consider that should you switch to swing classes.


Dean
Technical Details
Message-ID: <35255702.BEA2E5A9@us.ibm.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <6g3fjn$rhj$1@Nntp1.mcs.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,d4aacaa358cff2dc
X-Google-Attributes: gidf74b3,public
From: Dean Henkel <henkel@us.ibm.com>
Subject: Re: textValueChanged event
Date: 1998/04/03
Message-ID: <35255702.BEA2E5A9@us.ibm.com>
X-Deja-AN: 340633388
Content-Transfer-Encoding: 7bit
References: <6g3fjn$rhj$1@Nntp1.mcs.net>
Content-Type: text/plain; charset=us-ascii
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language