I've rewritten this question as i've localized the problem but don't understand it ..
I'm experimenting with Griffon .. In a view class I had some code ..
new Timer(1000, { e ->
controller.countDown()
} as ActionListener).start()
which works fine (it drives a countdown clock on the corresponding view so i'm not certain its the correct place to put it .. but it works)
I moved the code to the controller in the corresponding controllers mvcGroupInit routine and got an error .. so i changed the implementation to Java ..
Timer myTimer = new Timer(1000, new ActionListener() {
void actionPerformed(ActionEvent e) {
//countDown()
println "Mmm ? "
}
} )
and I get an error ..
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)
which points to
Timer myTimer = new Timer(1000, new ActionListener() {
void actionPerformed(ActionEvent e) { ....
So I copied the code into the groovy console ..
import java.awt.event.*
new Timer(1000, {e->
println "running .."
} as ActionListener).start()
and ran it .. got
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)
I dont understand why Groovy is objecting . Can someone enlighten me ?? Also is this a reasonable place to put this kind of timer given it updates a model which is reflected in the UI ..
I'm using Griffon 1.4 / Java 1.7 / .. Thanks again ..
You are getting the wrong Timer
class (by default): java.util.Timer
is there because everything from java.util
is imported automatically in groovy. Use instead a FQN:
new javax.swing.Timer(1000, ...