andyberlin2000
Programmer
I have a main programm (Java) calling service classes (Groovy). Even though libs are in place (compilation is o.k.) runtime doesn't recognize swing features and usually no Groovy specific syntax (especially listener).
"groovy.lang.MissingPropertyException: No such Property:
addActionListener for class javax.swing.JButton".
This looks like a Java problem - because Java features are concerned, I am not using Groovy specific features except the listener syntax. But compilation will change that to plain Java, right ?
I tried joint / single compilation - same result. Does anybody have a hint for me what to do? I need groovy features to be done by groovy (DSL, SwingBuilder, XML...)
Example code:
-------------
START:BAT // START_JOINT.BAT
***************
java -cp %GROOVY_HOME%/embeddable/groovy-all-1.6.1.jar;../classes Starter //
java -cp %GROOVY_HOME%/embeddable/groovy-all-1.6.1.jar;../jointclasses Starter
pause
Starter.java
************
import grlib.*;
public class Starter
{
public static void main (String[] args)
{ System.out.println("\n\nStarting Sw.groovy....\n\n");
Sw sw = new Sw();
}
} //----------------------------------------------------------
Sw.groovy
*********
package grlib;
import javax.swing.*
import java.awt.*
import java.awt.event.*
public class Sw
{
public Sw()
{
def swing = new SwingBuilder()
JFrame frame = new JFrame(size: [300, 300],
layout: new FlowLayout(),
defaultCloseOperation: javax.swing.WindowConstants.EXIT_ON_CLOSE)
JButton button = new JButton("click" )
JLabel positionLabel = new JLabel("" )
JLabel msgLabel = new JLabel("" )
frame.contentPane.add button
frame.contentPane.add positionLabel
frame.contentPane.add msgLabel
button.addActionListener
( { JOptionPane.showMessageDialog(frame, "You clicked!" ) }
as ActionListener
) ....................
"groovy.lang.MissingPropertyException: No such Property:
addActionListener for class javax.swing.JButton".
This looks like a Java problem - because Java features are concerned, I am not using Groovy specific features except the listener syntax. But compilation will change that to plain Java, right ?
I tried joint / single compilation - same result. Does anybody have a hint for me what to do? I need groovy features to be done by groovy (DSL, SwingBuilder, XML...)
Example code:
-------------
START:BAT // START_JOINT.BAT
***************
java -cp %GROOVY_HOME%/embeddable/groovy-all-1.6.1.jar;../classes Starter //
java -cp %GROOVY_HOME%/embeddable/groovy-all-1.6.1.jar;../jointclasses Starter
pause
Starter.java
************
import grlib.*;
public class Starter
{
public static void main (String[] args)
{ System.out.println("\n\nStarting Sw.groovy....\n\n");
Sw sw = new Sw();
}
} //----------------------------------------------------------
Sw.groovy
*********
package grlib;
import javax.swing.*
import java.awt.*
import java.awt.event.*
public class Sw
{
public Sw()
{
def swing = new SwingBuilder()
JFrame frame = new JFrame(size: [300, 300],
layout: new FlowLayout(),
defaultCloseOperation: javax.swing.WindowConstants.EXIT_ON_CLOSE)
JButton button = new JButton("click" )
JLabel positionLabel = new JLabel("" )
JLabel msgLabel = new JLabel("" )
frame.contentPane.add button
frame.contentPane.add positionLabel
frame.contentPane.add msgLabel
button.addActionListener
( { JOptionPane.showMessageDialog(frame, "You clicked!" ) }
as ActionListener
) ....................