-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.2.0
-
generic
-
generic
Name: rm29839 Date: 03/13/98
The following Exception trace is generated when using key board input
in JTextFields or using the "arrow" keys to activate a JSlider.
Java Configuration: Swing-1.0.1 and jdk1.2beta2
Key points:
o) JFrame contains:
> JMenuBar
> JPanel as a GridBag
> JLabel
> JTabbedPane
> JPanel as GridLayout
> JLabel
> JTextField
Exception occurred during event dispatching:
java.lang.NullPointerException
at com.sun.java.swing.JMenuBar.bindingForKeyStrokeRecursive(JMenuBar.java:559)
at com.sun.java.swing.JMenuBar.bindingForKeyStroke(JMenuBar.java:532)
at com.sun.java.swing.JComponent.processKeyBinding(JComponent.java:1345)
at com.sun.java.swing.JComponent.processKeyBindingsForAllComponents(JComponent.java:1402)
at com.sun.java.swing.JComponent.processKeyBindingsForAllComponents(JComponent.java:1409)
at com.sun.java.swing.JComponent.processKeyBindingsForAllComponents(JComponent.java:1409)
at com.sun.java.swing.JComponent.processKeyBindingsForAllComponents(JComponent.java:1409)
at com.sun.java.swing.JComponent.processKeyBindings(JComponent.java:1391)
at com.sun.java.swing.JComponent.processKeyEvent(JComponent.java:1281)
at java.awt.Component.processEvent(Component.java:2347)
at java.awt.Container.processEvent(Container.java:889)
at java.awt.Component.dispatchEventImpl(Component.java:1909)
at java.awt.Container.dispatchEventImpl(Container.java:934)
at java.awt.Component.dispatchEvent(Component.java:1824)
at java.awt.LightweightDispatcher.processKeyEvent(Container.java:1408)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:1392)
at java.awt.Container.dispatchEventImpl(Container.java:921)
at java.awt.Window.dispatchEventImpl(Window.java:517)
at java.awt.Component.dispatchEvent(Component.java:1824)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:45)
Source to reproduce the problem follows:
import com.sun.java.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Bug extends JFrame {
private GridBagLayout gbag = new GridBagLayout();
private GridBagConstraints c = new GridBagConstraints();
public Bug () {
// build a menu bar
JMenu file;
JMenuBar mainMenu = new JMenuBar();
file = new JMenu("File");
file.setMnemonic('F');
mainMenu.add(file);
setJMenuBar(mainMenu);
// set up the contents of the rest of the frame
JPanel p = new JPanel();
p.setLayout(new GridLayout(1, 2));
p.add(new JLabel("Type here for exceptions"));
p.add(new JTextField(6));
JTabbedPane tp = new JTabbedPane();
tp.addTab("Error", null, p, null);
JPanel q = new JPanel();
q.setLayout(gbag);
JLabel ql = new JLabel("JLabel Text");
c.gridx = 0;
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.NORTH;
c.weightx = 1;
c.weighty = 0.1;
((GridBagLayout)q.getLayout()).setConstraints(ql, c);
q.add(ql);
c.gridheight = GridBagConstraints.REMAINDER;
c.weighty = 0.9;
((GridBagLayout)q.getLayout()).setConstraints(tp, c);
q.add(tp);
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(q);
this.setTitle("KeyStroke Errors");
this.setSize(350,150);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) { System.exit(0); }
});
}
public static void main(String argv[]) {
Bug bg = new Bug();
bg.setVisible(true);
}
}
(Review ID: 26179)
======================================================================
- duplicates
-
JDK-4116152 JMenuBar.bindingForKeyStrokeRecursive NPE
-
- Resolved
-