bug-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug classpath/22964] swing: keyTyped sent before newline has been added


From: gcc-bugzilla at gcc dot gnu dot org
Subject: [Bug classpath/22964] swing: keyTyped sent before newline has been added to JTextArea
Date: 16 Oct 2005 01:27:48 -0000

Steps to reproduce:
1. Compile and run the attached testcase.
2. Hit enter over the textarea.

Expected results:
1. Programs prints the following to stdout
keyPressed, length now 0
keyTyped, length now 1
keyReleased, length now 1

Actual results:
1. Program prints the following to stdout
keyPressed, length now 0
keyTyped, length now 0
keyReleased, length now 1

Testcase:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class keyhandler extends JFrame {
        private JTextArea a;
        public static void main(String[] args) {
                (new keyhandler()).show();
        }
        public keyhandler() {
                this.a = new JTextArea(80, 25);
                this.a.addKeyListener(new KeyHandler());
                this.setContentPane(a);
                this.setSize(new Dimension(400, 400));
        }
        private class KeyHandler implements KeyListener {
                public void keyTyped(KeyEvent e) {
                        System.out.println("keyTyped, length now " +
keyhandler.this.a.getText().length());
                }
                public void keyPressed(KeyEvent e) {
                        System.out.println("keyPressed, length now " +
keyhandler.this.a.getText().length());
                }
                public void keyReleased(KeyEvent e) {
                        System.out.println("keyReleased, length now " +
keyhandler.this.a.getText().length());
                }
        }
}

Note that this bug seems to happen only with newline characters, typing
anything else won't trigger the bug.


------- Comment #1 from from-classpath at savannah dot gnu dot org  2005-06-03 
13:19 -------
Hmm, I don't know if we should care about that. I can confirm that newline
characters are counted before the KEY_TYPED is sent on the JDK and other
characters after sending the KEY_TYPED event. GNU Classpath inserts the
characters after KEY_TYPED in any case. The question is, if this _slight_
diversion from Sun's behaviour does hurt anybody.? 


------- Comment #2 from from-classpath at savannah dot gnu dot org  2005-06-03 
13:44 -------
Well, it breaks at least EsoShell, http://lilly.csoft.net/~jeffryj/EsoShell 


------- Comment #3 from from-classpath at savannah dot gnu dot org  2005-06-08 
10:01 -------
Whoo, this was tricky. I think I got it right. Could you retest this? I am
quite sure that this fix will trigger new bugs, especially some keys will not
be recognized correctly. Please open new bug reports if you find some!


------- Comment #4 from from-classpath at savannah dot gnu dot org  2005-06-08 
11:17 -------
Both testcase and the actual application (esoshell) don't seem to suffer from
this bug anymore (esoshell is affected by some repainting problem though).


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22964





reply via email to

[Prev in Thread] Current Thread [Next in Thread]