Griffon/Groovy编程错误:don';我不明白
我已经重写了这个问题,因为我已经将问题本地化了,但不理解它 我在用狮鹫做实验。。在视图类中,我有一些代码Griffon/Groovy编程错误:don';我不明白,groovy,griffon,Groovy,Griffon,我已经重写了这个问题,因为我已经将问题本地化了,但不理解它 我在用狮鹫做实验。。在视图类中,我有一些代码 new Timer(1000, { e -> controller.countDown() } as ActionListener).start() 工作正常(它在相应的视图上驱动倒计时时钟,所以我不确定它放在正确的位置..但它工作正常) 我将代码移动到相应控制器mvcGroupInit例程中的控制器,并得到一个错误。。因此,我将实现更改为Java Timer myTimer
new Timer(1000, { e ->
controller.countDown()
} as ActionListener).start()
工作正常(它在相应的视图上驱动倒计时时钟,所以我不确定它放在正确的位置..但它工作正常)
我将代码移动到相应控制器mvcGroupInit例程中的控制器,并得到一个错误。。因此,我将实现更改为Java
Timer myTimer = new Timer(1000, new ActionListener() {
void actionPerformed(ActionEvent e) {
//countDown()
println "Mmm ? "
}
} )
我得到一个错误
2014-10-08 10:13:46,695 [main] INFO griffon.swing.SwingApplication - Initializing all startup groups: [sequenceMonitor]
2014-10-08 10:13:49,391 [main] ERROR griffon.util.GriffonExceptionHandler - Uncaught Exception
groovy.lang.GroovyRuntimeException: Could not find matching constructor for: java.util.Timer(java.lang.Integer, sequencemonitor.SequenceMonitorController$1)
at sequencemonitor.SequenceMonitorController.mvcGroupInit(SequenceMonitorController.groovy:36)
哪个指向
Timer myTimer = new Timer(1000, new ActionListener() {
void actionPerformed(ActionEvent e) { ....
因此,我将代码复制到groovy控制台中
import java.awt.event.*
new Timer(1000, {e->
println "running .."
} as ActionListener).start()
然后运行它。。得到
WARNING: Sanitizing stacktrace:
groovy.lang.GroovyRuntimeException: Could not find matching constructor for: java.util.Timer(java.lang.Integer, com.sun.proxy.$Proxy12)
at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1550)
at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1404)
at org.codehaus.groovy.runtime.callsite.MetaClassConstructorSite.callConstructor(MetaClassConstructorSit e.java:46)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:194)
at ConsoleScript9.run(ConsoleScript9:3)
我不明白Groovy为什么反对。有人能启发我吗??鉴于计时器更新了反映在用户界面中的模型,这也是放置此类计时器的合理位置
我使用的是Griffon1.4/Java1.7/。。
再次感谢 您得到了错误的
Timer
类(默认情况下):java.util.Timer
存在,因为java.util
中的所有内容都在groovy中自动导入。请改用FQN:
new javax.swing.Timer(1000, ...