-
Bug
-
Resolution: Fixed
-
P4
-
1.4.0, 1.4.2, 5.0u4, 8
-
b10
-
generic, x86, sparc
-
generic, solaris, solaris_9, windows_xp
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8276875 | 17.0.3-oracle | Alex Kasko | P4 | Resolved | Fixed | b01 |
JDK-8276720 | 17.0.2 | Alex Kasko | P4 | Resolved | Fixed | b04 |
JDK-8295131 | 11.0.18 | Goetz Lindenmaier | P4 | Resolved | Fixed | b01 |
JDK-8290637 | 11.0.17-oracle | Maheshkumar Bollapragada | P4 | Resolved | Fixed | b03 |
JDK-8290634 | 8u351 | Maheshkumar Bollapragada | P4 | Resolved | Fixed | b03 |
Name: dk106046 Date: 02/17/2003
In the JTable demo, if I double click on the first cell in the Favorite Number column, delete the value and click on some
other cell, a java.lang.NullPointerException is getting thrown.
*****************************************************************************************************************************
java.lang.NullPointerException
at TableDemo$10.getColumnClass(TableDemo.java:498)
at javax.swing.JTable.getColumnClass(JTable.java:1762)
at javax.swing.JTable.getCellRenderer(JTable.java:3683)
at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:1177)
at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:1080
)
at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:1003)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:162)
at javax.swing.JComponent.paintComponent(JComponent.java:566)
at javax.swing.JComponent.paint(JComponent.java:833)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4885)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4838)
at javax.swing.JComponent._paintImmediately(JComponent.java:4782)
at javax.swing.JComponent.paintImmediately(JComponent.java:4591)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:430)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(System
EventQueueUtilities.java:137)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:204)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:526)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:237)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:181)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:175)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:167)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:130)
*****************************************************************************************************************************
Expected Result
The exception should not get thrown.
Steps to Recreate:
1) cd to \Java141\demo\jfc\SwingSet2
2) enter appletviewer SwingSet2.html
3) Select the JTable demo
4) Double click on the first cell in the Favorite Number column. Delete the value. Click on another cell.
For empty cells, getValueAt(row, col) method returns null and hence getColumnClass() method
in TableDemo throws NPE.
I can think of two fixes for this bug.
1) ----------------------
public Class getColumnClass(int c)
{
Object obj = null;
for (int i=0; i<getRowCount(); i++)
{
obj=getValueAt(i, c);
if(obj!=null) return obj.getClass();
}
return Object.class;
}
------------------------
2)---------------------
public Class getColumnClass(int c)
{
return c==4 ? Double.class : getValueAt(0, c).getClass();
}
-----------------------
I am going for fix 2, as 5th column (ie. c=4) will be always Double.
======================================================================
- backported by
-
JDK-8276720 SwingSet2 JTable Demo throws NullPointerException
- Resolved
-
JDK-8276875 SwingSet2 JTable Demo throws NullPointerException
- Resolved
-
JDK-8290634 SwingSet2 JTable Demo throws NullPointerException
- Resolved
-
JDK-8290637 SwingSet2 JTable Demo throws NullPointerException
- Resolved
-
JDK-8295131 SwingSet2 JTable Demo throws NullPointerException
- Resolved
- duplicates
-
JDK-6315769 SwingSet2 Demo: exceptions thrown out when one cell is empty in JTable demo
- Closed
-
JDK-4849177 NPE thrown in Table Demo of SwingSet2
- Closed
- relates to
-
JDK-5077727 JTable throws exception when cell is cleared in GTK L&F
- Closed
- links to
-
Commit openjdk/jdk11u-dev/df6d5f8f
-
Commit openjdk/jdk17u/9a2c123d
-
Commit openjdk/jdk/64d18d45
-
Review openjdk/jdk11u-dev/1411
-
Review openjdk/jdk17u/163
-
Review openjdk/jdk/4969