Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.4
-
None
Description
In order for mutable numbers to be used in editable JTable models, they need to have a constructor accepting a string. The following stack trace was the result of double-clicking on a table cell displaying a MutableDouble instance:
java.lang.NoSuchMethodException: org.apache.commons.lang.mutable.MutableDouble.<init>(java.lang.String)
at java.lang.Class.getConstructor0(Class.java:2678)
at java.lang.Class.getConstructor(Class.java:1629)
at org.jdesktop.swingx.table.NumberEditorExt.getTableCellEditorComponent(NumberEditorExt.java:107)
Caused: java.lang.IllegalStateException: Number subclass must have a constructor which takes a string
at org.jdesktop.swingx.table.NumberEditorExt.getTableCellEditorComponent(NumberEditorExt.java:110)
at javax.swing.JTable.prepareEditor(JTable.java:3983)
at org.jdesktop.swingx.JXTable.prepareEditor(JXTable.java:3458)
at javax.swing.JTable.editCellAt(JTable.java:2688)
at org.jdesktop.swingx.JXTable.editCellAt(JXTable.java:3852)
at javax.swing.plaf.basic.BasicTableUI$Handler.adjustFocusAndSelection(BasicTableUI.java:955)
at javax.swing.plaf.basic.BasicTableUI$Handler.mousePressed(BasicTableUI.java:922)
at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:222)
at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:221)
at java.awt.Component.processMouseEvent(Component.java:5514)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
at java.awt.Component.processEvent(Component.java:5282)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3984)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3819)
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:1791)
at java.awt.Component.dispatchEvent(Component.java:3819)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
The editor had been installed in this way:
JTable table = ...;
table.setDefaultEditor(Number.class, table.getDefaultEditor(Double.class));