Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4419219

Regression: Activating an Unregistered key action event causes NPE

XMLWordPrintable

    • ladybird
    • x86
    • windows_nt



        Name: boT120536 Date: 02/26/2001


        description : java version "1.3.0"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
        Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)


        The registerKeyboardAction() method was NOT deprecated in 1.3, but you
        implemented workarounds that crash.ActionStandin should not crash.

        This code works in 1.2.2 when you press CTRL-A, nothing happens.
        in 1.3.0 it Crashes with a NPE

          To reproduce the problem modify
        jdk1.3/demo/jfc/TableExample/src/TableExample4.java

        Add the appropriate imports:
        import javax.swing.event.*;
        import java.awt.event.*;

        Add registerKeyboardAction() after JTable creation:
        // Create the table
        JTable tableView = new JTable(dataModel);

        // unregister ctrl-A
        tableView.registerKeyboardAction(null, KeyStroke.getKeyStroke(KeyEvent.V
        K_A, ActionEvent.CTRL_MASK), JComponent.WHEN_FOCUSED);

        Compile and run. Press <CTRL>A. The app crashes in 1.3 it does not in 1.2.2.

        java.lang.NullPointerException
            at
        javax.swing.JComponent$ActionStandin.actionPerformed(JComponent.java:2446)
            at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1702)
            at javax.swing.JComponent.processKeyBinding(JComponent.java:2156)
            at javax.swing.JTable.processKeyBinding(JTable.java:3111)
            at javax.swing.JComponent.processKeyBindings(JComponent.java:2182)
            at javax.swing.JComponent.processKeyEvent(JComponent.java:2119)
            at java.awt.Component.processEvent(Component.java:3555)
            at java.awt.Container.processEvent(Container.java:1164)
            at java.awt.Component.dispatchEventImpl(Component.java:2595)
            at java.awt.Container.dispatchEventImpl(Container.java:1213)
            at java.awt.Component.dispatchEvent(Component.java:2499)
            at java.awt.LightweightDispatcher.processKeyEvent(Container.java:2155)
            at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2135)
            at java.awt.Container.dispatchEventImpl(Container.java:1200)
            at java.awt.Window.dispatchEventImpl(Window.java:912)
            at java.awt.Component.dispatchEvent(Component.java:2499)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:319)
            at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:106)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)

        (Review ID: 117584)
        ======================================================================

              svioletsunw Scott Violet (Inactive)
              bonealsunw Bret O'neal (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: