JDK-4659800 : REGRESSION: Hitting enter on focused JButton no longer causes action.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2002-03-28
  • Updated: 2002-06-16
  • Resolved: 2002-04-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.1 hopperFixed
Related Reports
Relates :  
Description

Name: gm110360			Date: 03/28/2002


FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

FULL OPERATING SYSTEM VERSION :

Microsoft Windows 2000 [Version 5.00.2195]

A DESCRIPTION OF THE PROBLEM :
When using Windows LookAndFeel, a button that has focus
used to (in 1.3.1) fire an action event when the <ENTER>
key was pressed. It no longer does this. I cannot find any
documentation stating that this has changed.

REGRESSION.  Last worked in version 1.3.1

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.run program in 1.4
2.hit <ENTER> key
3.Notice that there is no System.out
4.Run program in 1.3 and repeat. Notice that there is a
System.out

EXPECTED VERSUS ACTUAL BEHAVIOR :
Expect the Button to be depressed and an action event to
occur when it has focus and <ENTER> is pressed. This no
longer happens.

This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.*;
import javax.swing.text.*;
import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
import java.awt.*;
import java.awt.event.*;

public class ButtonTest extends JFrame
{
	JButton butt1;

    public ButtonTest()
    {
        try
        {
            UIManager.setLookAndFeel(new
com.sun.java.swing.plaf.windows.WindowsLookAndFeel());
        }
        catch(Exception e){}
        
        JPanel panel = new JPanel();
        panel.setLayout(new FlowLayout());
		butt1 = new JButton("butt1");
		butt1.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent e)
			{
				System.err.println("button pushed");
			}
		});
		
        panel.add(butt1);
		panel.add(new JButton("butt2"));
        getContentPane().add(panel);
        setLocation(100,100);
        setSize(250,250);
        setVisible(true);
        butt1.requestFocus();
    }

    public static void main(String[] args)
    {
        ButtonTest inputTest1 = new ButtonTest();
    }
    
}

---------- END SOURCE ----------

CUSTOMER WORKAROUND :
Could add a key listener to self and fire event when enter
pushed.

Release Regression From : 1.3.1_02
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.

(Review ID: 144742) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: hopper FIXED IN: hopper INTEGRATED IN: hopper VERIFIED IN: hopper-beta
14-06-2004

EVALUATION Reassigning to swing for their evaluation. ###@###.### 2002-03-29 With the Windows look and feel, the default button should follow the focus. It is the default button that is activated by an ENTER press. The problem is that this default-follows-focus only works right now if an initial default button is set with setDefaultButton() on JRootPane. I have now fixed it to work properly even when a default is not explicitly set. ###@###.### 2002-04-02
02-04-2002