-
Bug
-
Resolution: Fixed
-
P3
-
5.0
-
b60
-
generic
-
generic
-
Verified
In GTK L&F if a table cell which was of Number type is cleared, exception is thrown. This has been occuring from b37 onwards. The exception thrown is:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Cannot format given Object as a Number
at java.text.DecimalFormat.format(DecimalFormat.java:480)
at java.text.Format.format(Format.java:133)
at javax.swing.plaf.synth.SynthTableUI$SynthTableCellRenderer.configureValue(SynthTableUI.java:569)
at javax.swing.plaf.synth.SynthTableUI$SynthTableCellRenderer.getTableCellRendererComponent(SynthTableUI.java:556)
at javax.swing.JTable.prepareRenderer(JTable.java:3919)
at javax.swing.plaf.synth.SynthTableUI.paintCell(SynthTableUI.java:450)
at javax.swing.plaf.synth.SynthTableUI.paintCells(SynthTableUI.java:347)
at javax.swing.plaf.synth.SynthTableUI.paint(SynthTableUI.java:262)
at javax.swing.plaf.synth.SynthTableUI.update(SynthTableUI.java:210)
at javax.swing.JComponent.paintComponent(JComponent.java:740)
at javax.swing.JComponent.paint(JComponent.java:1003)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4930)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4883)
at javax.swing.JComponent._paintImmediately(JComponent.java:4826)
at javax.swing.JComponent.paintImmediately(JComponent.java:4633)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:451)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:114)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
This appears is due to improper handling of empty values by SynthTableUI. It tries to format the content of the cell without checking for empty value. Other L&Fs handles it properly.
The JTable code has the following:
setText((value == null) ? "" : formatter.format(value));
Where as the SynthTableUI does it as:
setText(((NumberFormat)numberFormat).format(value));
Because of this, a code which was working on GTK L&F in 1.4 will throw exceptions now.
To reproduce the issue:
1. Launch SwingSet2 demo
2. Switch to GTK L&F and select JTable demo
3. Edit the 'favorite number' column and clear any of the entry in one row (Not the first row) and type enter
It can be seen that the exception is thrown.
Clearing the first row throws a NullPointerException which is a bug in the demo code. The code tries to find the class of the new value and throws a NullPointer exception. This occurs in all L&Fs. The exception is:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at TableDemo$15.getColumnClass(TableDemo.java:550)
at javax.swing.JTable.getColumnClass(JTable.java:1833)
at javax.swing.JTable.getCellEditor(JTable.java:3949)
at javax.swing.JTable.editCellAt(JTable.java:2635)
at javax.swing.plaf.basic.BasicTableUI$Handler.adjustFocusAndSelection(BasicTableUI.java:922)
at javax.swing.plaf.basic.BasicTableUI$Handler.mousePressed(BasicTableUI.java:889)
at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:222)
at java.awt.Component.processMouseEvent(Component.java:5485)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3093)
at java.awt.Component.processEvent(Component.java:5253)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3889)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1766)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Cannot format given Object as a Number
at java.text.DecimalFormat.format(DecimalFormat.java:480)
at java.text.Format.format(Format.java:133)
at javax.swing.plaf.synth.SynthTableUI$SynthTableCellRenderer.configureValue(SynthTableUI.java:569)
at javax.swing.plaf.synth.SynthTableUI$SynthTableCellRenderer.getTableCellRendererComponent(SynthTableUI.java:556)
at javax.swing.JTable.prepareRenderer(JTable.java:3919)
at javax.swing.plaf.synth.SynthTableUI.paintCell(SynthTableUI.java:450)
at javax.swing.plaf.synth.SynthTableUI.paintCells(SynthTableUI.java:347)
at javax.swing.plaf.synth.SynthTableUI.paint(SynthTableUI.java:262)
at javax.swing.plaf.synth.SynthTableUI.update(SynthTableUI.java:210)
at javax.swing.JComponent.paintComponent(JComponent.java:740)
at javax.swing.JComponent.paint(JComponent.java:1003)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4930)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4883)
at javax.swing.JComponent._paintImmediately(JComponent.java:4826)
at javax.swing.JComponent.paintImmediately(JComponent.java:4633)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:451)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:114)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
This appears is due to improper handling of empty values by SynthTableUI. It tries to format the content of the cell without checking for empty value. Other L&Fs handles it properly.
The JTable code has the following:
setText((value == null) ? "" : formatter.format(value));
Where as the SynthTableUI does it as:
setText(((NumberFormat)numberFormat).format(value));
Because of this, a code which was working on GTK L&F in 1.4 will throw exceptions now.
To reproduce the issue:
1. Launch SwingSet2 demo
2. Switch to GTK L&F and select JTable demo
3. Edit the 'favorite number' column and clear any of the entry in one row (Not the first row) and type enter
It can be seen that the exception is thrown.
Clearing the first row throws a NullPointerException which is a bug in the demo code. The code tries to find the class of the new value and throws a NullPointer exception. This occurs in all L&Fs. The exception is:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at TableDemo$15.getColumnClass(TableDemo.java:550)
at javax.swing.JTable.getColumnClass(JTable.java:1833)
at javax.swing.JTable.getCellEditor(JTable.java:3949)
at javax.swing.JTable.editCellAt(JTable.java:2635)
at javax.swing.plaf.basic.BasicTableUI$Handler.adjustFocusAndSelection(BasicTableUI.java:922)
at javax.swing.plaf.basic.BasicTableUI$Handler.mousePressed(BasicTableUI.java:889)
at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:222)
at java.awt.Component.processMouseEvent(Component.java:5485)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3093)
at java.awt.Component.processEvent(Component.java:5253)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3889)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1766)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
- relates to
-
JDK-4976756 ControlPanel throws java.lang.NullPointerException in "JNLP Runtime Settings"
- Resolved
-
JDK-4819544 SwingSet2 JTable Demo throws NullPointerException
- Resolved