JDK-4028470 : The keyTyped() method is called for the listeners of the TextField before the st
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.1
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_nt
  • CPU: x86
  • Submitted: 1997-01-28
  • Updated: 2005-12-06
Related Reports
Relates :  
Description
Name: mc57594			Date: 01/28/97


When establishing yourself as a listener for a KeyListener
events on a TextField object, the value obtained from 
	a call to getText() on the TextField object returns the value of the
TextField before applying the the key pressed that
	caused the event to be triggered.  The TextField show be updated BEFORE
a call, I beleive.
======================================================================

Comments
WORK AROUND Name: mc57594 Date: 01/28/97 None ======================================================================
17-09-2004

EVALUATION Is this intentional? I guess keyPressed should be called befor the text is added, but what about keyTyped? Does setting the consumed flag on keyTyped prevent the text from being added? ============================================================================ eric.hawkes@eng 1998-02-23 See also bugs 4075192, 4079012, 4025930, 4059600, 4069196, 4078774, 4100317, 4087389, and especially 4114565. Name: rrT76497 Date: 05/20/98 /** * Run this program KeyTyped event will trigger in between * KeyPressed and KeyRealesed ,This sequence is not correct KeyTyped * should trigger after the two events.In win32 KeyTyped triggers wont select * the key just pressed in getText() method but it is got selected in Solaris. */ import java.awt.*; import java.awt.event.*; public class TextFieldgetTextTest extends Frame implements KeyListener { TextField text = new TextField(10); public TextFieldgetTextTest(){ text.addKeyListener(this); add(text); pack(); setVisible(true); } public void keyTyped(KeyEvent e){ System.out.println("KeyTyped :"+text.getText()); } public void keyPressed(KeyEvent e){ System.out.println("KeyPressed :"+text.getText()); } public void keyReleased(KeyEvent e){ System.out.println("KeyRealesed :"+text.getText()); } public static void main(String[] aw) { new TextFieldgetTextTest(); } } ====================================================================== Tested under WinNT 4.0 SP5 and Sun4 Solaris 2.7 using JDK 1.3RA. The bug was reproducible under Solaris. sandeep.konchady@Eng 1999-11-24 Name: dsR10078 Date: 07/02/2001 Tested with merlin b69. Both on Solaris and Win32 the events are dispatched in the following order: KeyPressed : KeyTyped : KeyRealeased :a Both on Solaris and Win32 the text is updated after KeyTyped. The difference is that when a key is pressed for a long time on Solaris KeyRealeased is generated for each KeyPressed/KeyReleased pair while on Win32 it is generated only when the key is released. ###@###.### 2001-07-02 ======================================================================
02-07-2001