DZone Forums
Go Back   DZone Forums > Community > Languages & Frameworks > Groovy & Grails
Reload this Page Java-Groovy integration
Notices
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  (#1 (permalink)) Old
Member
 
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Join Date: Jun 2009
Default Java-Groovy integration - 06-22-2009, 03:55 AM

I know Java but am new to groovy. I don't understand what goes wrong (only runtime problem, compilation o.k.) and would appreciate any help. Thanks a lot in advance!
------------------------------------------------------

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".

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
) ....................
Reply With Quote
Reply

Tags
groovy, integration, java

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Eclipse Bazaar Integration, new features request. javierder Eclipse 0 05-26-2009 09:41 AM
NetBeans Now Provides Project Kenai Integration sc46163 NetBeans 0 05-14-2009 01:58 PM
Maven Integration problem shamsulkamal Eclipse 1 03-09-2009 02:32 PM
Eclipse is too slow for editing Groovy code sontrang91 Eclipse 0 09-23-2008 11:55 PM
Unit/Integration Testing Eclipse RCP app gommo Eclipse 0 07-08-2008 12:08 AM


Copyright 1997-2009, DZone, Inc.
vBulletin Skin developed by: vBStyles.com