JDK-4910211 : "alt" key causes java.lang.NullPointerException in 1.5b14
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.2,5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_2000,windows_xp
  • CPU: x86
  • Submitted: 2003-08-21
  • Updated: 2004-04-29
  • Resolved: 2003-09-05
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 Availabitlity Release.

To download the current JDK release, click here.
Other
1.4.2_05 05Fixed
Related Reports
Duplicate :  
Description
When the cursor moves on a dialogue and press "alt" key,
Thej ava.lang.NullPointerException  exception occurs both in 1.4.2fcs 
and 1.5(b14).

This issues does not occurs in 1.4.1_0X.
It seems regression.

Configration:
  OS Windows2000/WindowsXP, both are japanese edition.

Reproduce:
  1) Compile the attached test Case.
  2) Invoke " java Test'
  3) Click the "dialog" button in opened window and
     you will see a dialog appears.
  4) Move the pointer in the dialog and press the "alt" key.

The exception in the attached file "log-1.5b14.txt"  will show up.


Test Case:

==== Test.java =====>
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Test extends JFrame implements ActionListener {

    public JButton  button = new JButton("Dialog");

    public Test() {

        try {

            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLoo
kAndFeel");

            setSize(300,300);
            getContentPane().setBackground(Color.white);
            getContentPane().setLayout(null);
            getContentPane().add(button);

            button.setBounds(100,100,100,50);
            button.addActionListener(this) ;

            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        } catch (Exception ex) {
            System.out.println(ex);
        }

    }

    public void actionPerformed(ActionEvent e) {
        Dialog dialog = new Dialog(this,true);
        dialog.setSize(200,200);
        dialog.show();
    }

    public static void main(String[] argv) {

        Test test = new Test();
        test.show();

    }

}

<=== Test.java =====


==============================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.4.2_05 generic tiger FIXED IN: 1.4.2_05 tiger INTEGRATED IN: 1.4.2_05 tiger tiger-b19 VERIFIED IN: 1.4.2_05
2004-08-24

SUGGESTED FIX ------- WindowsRootPaneUI.java ------- *** /tmp/sccs.mLaOO2 Fri Aug 22 12:33:46 2003 --- WindowsRootPaneUI.java Fri Aug 22 12:33:08 2003 *************** *** 155,161 **** public boolean postProcessKeyEvent(KeyEvent ev) { if (ev.getKeyCode() == KeyEvent.VK_ALT) { root = SwingUtilities.getRootPane(ev.getComponent()); ! winAncestor = SwingUtilities.getWindowAncestor(root); if (ev.getID() == KeyEvent.KEY_PRESSED) { if (!altKeyPressed) { --- 155,162 ---- public boolean postProcessKeyEvent(KeyEvent ev) { if (ev.getKeyCode() == KeyEvent.VK_ALT) { root = SwingUtilities.getRootPane(ev.getComponent()); ! winAncestor = (root == null ? null : ! SwingUtilities.getWindowAncestor(root)); if (ev.getID() == KeyEvent.KEY_PRESSED) { if (!altKeyPressed) {
2004-08-24

EVALUATION The reason of this bug is that we are trying to get the window ancestor of the null component. The idea of suggested fix is to assume that null component have null window ancestor. ###@###.### 2003-08-22 Fix verified on Winxp Home for build 1.4.2_05-ea-b01 ###@###.### 2004-04-29
2003-08-22