Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.0
-
None
-
None
Description
Hey,
I copied the class below into a groovy script and I got the following error:
class MyJComboBox extends JComboBox implements
javax.swing.table.TableCellRenderer {
MyJComboBox(items) {
super()
items?.each
}
Component getTableCellRendererComponent(
JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column) {
if (isSelected) { setForeground(table.getSelectionForeground()); super.setBackground(table.getSelectionBackground()); } else { setForeground(table.getForeground()); setBackground(table.getBackground()); }
return this;
}
}
Error:
====
Exception in thread "AWT-EventQueue-0" org.codehaus.groovy.runtime.InvokerInvoca
tionException: java.lang.VerifyError: (class: MyJComboBox, method: getTableCellR
endererComponent signature: (Ljavax/swing/JTable;Ljava/lang/Object;ZZII)Ljava/aw
t/Component Inconsistent stack height 0 != 1
at org.codehaus.groovy.runtime.ReflectionMetaMethod.invoke(ReflectionMet
aMethod.java:75)
at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassH
elper.java:713)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:560)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:450)
at groovy.lang.Closure.call(Closure.java:188)
at groovy.lang.Closure.call(Closure.java:201)
at groovy.model.ClosureModel.getValue(ClosureModel.java:87)
at groovy.model.DefaultTableColumn.getValue(DefaultTableColumn.java:82)
at groovy.model.DefaultTableModel.getValueAt(DefaultTableModel.java:168)
at javax.swing.JTable.getValueAt(JTable.java:1852)
at javax.swing.JTable.prepareRenderer(JTable.java:3902)
at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:1669)
at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:1571
)
at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:1494)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
at javax.swing.JComponent.paintComponent(JComponent.java:742)
at javax.swing.JComponent.paint(JComponent.java:1005)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JViewport.paint(JViewport.java:728)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4963)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4916)
at javax.swing.JComponent._paintImmediately(JComponent.java:4859)
at javax.swing.JComponent.paintImmediately(JComponent.java:4666)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:451)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(System
EventQueueUtilities.java:114)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.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)
Caused by: java.lang.VerifyError: (class: MyJComboBox, method: getTableCellRende
rerComponent signature: (Ljavax/swing/JTable;Ljava/lang/Object;ZZII)Ljava/awt/Co
mponent Inconsistent stack height 0 != 1
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at TRJIRA$run_closure1_closure3_closure7_closure12_closure13_closure15
closure18.class$(TRJIRA.groovy)
at TRJIRA$run_closure1_closure3_closure7_closure12_closure13_closure15
closure18.doCall(TRJIRA.groovy:75)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.codehaus.groovy.runtime.ReflectionMetaMethod.invoke(ReflectionMet
aMethod.java:69)
... 40 more
I then Groovy-fied the class as shown below and it made the error disappear:
class MyJComboBox extends JComboBox implements
javax.swing.table.TableCellRenderer {
MyJComboBox(items) {
super()
items?.each { addItem(it) }
}
Component getTableCellRendererComponent(
JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column) {
if (isSelected)
{ foreground = table.selectionForeground super.background = table.selectionBackground }else
{ foreground = table.foreground background = table.background } return this
}
}