classpath
[Top][All Lists]
Advanced

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

Re: javax.swing.JTextField


From: Anthony Balkissoon
Subject: Re: javax.swing.JTextField
Date: Tue, 20 Dec 2005 10:52:36 -0500

On Mon, 2005-12-19 at 22:40 -0500, Christopher Lansdown wrote:
> Hi,
> 
> JTextField doesn't seem to send any ActionEvent's when VK_ENTER is pressed,
> and looking through the source it doesn't seem to try to catch this.
> 

Hi Chris, I ran a little test program and it seems to work for me.  Are
you trying to activate the ActionEvent programmatically, or were you
actually typing the ENTER key into the text area?  Are you using the
newest Classpath?  

Here's a little test program to run, type in some text and hit enter.
Every time you hit enter "hi" is printed to the console.  Works for me.
If this little program doesn't work for anyone, or if you can write a
small program that shows what's wrong, please file a bug or email the
list again.

Test Program:
import java.awt.event.*;
import javax.swing.*;

public class Test
{ 
  public static void main(String[] args)
  {    
    JFrame jf = new JFrame();
    final JTextField text = new JTextField(10);
    text.addActionListener (new ActionListener()
      {
        public void actionPerformed(ActionEvent e)
        {
          System.out.println ("hi");
        }
      }
                            );
    jf.add(text);
    jf.pack();
    jf.setVisible(true);
  }
} 

--Tony







reply via email to

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