-
Bug
-
Resolution: Fixed
-
P4
-
1.2.2
-
kestrel
-
generic
-
generic
Name: krT82822 Date: 08/20/99
JTable: Pressing F2 on a non-editable cell throws
NullPointerException:
Simple example:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
public class JTableBugDemo {
public static void main(String s[]) {
JFrame frame = new JFrame();
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
JPanel p = new JPanel();
p.add(new JTable(new AbstractTableModel() {
Object[][] data = {{"1", "2"}, {"3", "4"}};
public boolean isCellEditable(int row, int column) {
return false;
}
public int getRowCount() {
return 2;
}
public int getColumnCount() {
return 2;
}
public Object getValueAt(int row, int column) {
return data[row][column];
}
}));
frame.getContentPane().add(p);
p.setVisible(true);
frame.pack();
frame.setVisible(true);
}
}
Run, and press F2 on any cell.
Trace:
Exception occurred during event dispatching:
java.lang.NullPointerException:
at javax.swing.plaf.basic.BasicTableUI$3.actionPerformed(BasicTableUI.java:675)
at javax.swing.JComponent.processKeyBinding(JComponent.java:1636)
at javax.swing.JComponent.processKeyBindings(JComponent.java:1649)
at javax.swing.JComponent.processKeyEvent(JComponent.java:1561)
at java.awt.Component.processEvent(Component.java, Compiled Code)
at java.awt.Container.processEvent(Container.java, Compiled Code)
at java.awt.Component.dispatchEventImpl(Component.java, Compiled Code)
at java.awt.Container.dispatchEventImpl(Container.java, Compiled Code)
at java.awt.Component.dispatchEvent(Component.java, Compiled Code)
at java.awt.LightweightDispatcher.processKeyEvent(Container.java:1766)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java, Compiled Code)
at java.awt.Container.dispatchEventImpl(Container.java, Compiled Code)
at java.awt.Window.dispatchEventImpl(Window.java, Compiled Code)
at java.awt.Component.dispatchEvent(Component.java, Compiled Code)
at java.awt.EventQueue.dispatchEvent(EventQueue.java, Compiled Code)
at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java, Compiled Code)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:92)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:83)
(Review ID: 94164)
======================================================================