Hi all,
Hmmm, this seems trickier than it ought to be (in my opinion). Even a
simple groovy version of the Hello World tutorial with an explicit call
to DesktopApplicationContext.main() is difficult to get running. The
reason for that is that DesktopApplicationContext.main() is using
Class.forName to load the instance of the Application class. Because
groovy uses its own specialized ClassLoader this fails (and I'm no
expert on "class loading", so I doubt I could explain this any better).
What *does* work is if I extract my "MyWindow" class into a separate
groovy file, use "groovyc" to compile that to a regular java .class file
and *then* run the example. But that's not very "scripty like".
Is it worth pursuing this any further, or is this going to be a dead-end
road?
Maarten
On 01/03/2013 11:10 AM, Maarten Boekhold wrote:
Hi all,
I've been reading up on Pivot to see if I'd be happy to use it as a
replacement for the simple Swing applications I sometimes need to
write, specifically because of the richness of the widgets that Pivot
provides.
Now, I prefer to write my small apps using Groovy, as a script. And
I'm not really seeing how the Pivot API fits into this model. Let me
explain with the following simple/dummy groovy script that opens 2
windows:
import groovy.swing.SwingBuilder
def builder = new SwingBuilder()
def f1 = builder.frame(title: 'Frame 1', pack: true, location:
[100, 100]) {
label(text: 'Frame 1')
}
def f2 = builder.frame(title: 'Frame 2', pack: true, location:
[300,300]) {
label(text: 'Frame 2')
}
f1.show()
f2.show()
println "do other stuff"
sleep 10*1000 // simulate "other stuff"
f1.dispose()
f2.dispose()
So far what I've read about Pivot tells me that in order to open an
application window, I need to write a class that implements
Application, and then use DesktopApplicationContext.main() to launch
that. That doesn't really seem to fit into the "scripting" paradigm
for me. Is there any way to get around this requirement of going
through DesktopApplicationContext and a class implementing Application?
Maarten