Skip to content
Skip to breadcrumbs
Skip to header menu
Skip to action menu
Skip to quick search
Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Sign Up
Dashboard
Groovy
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Page Layout
No Layout
Two column (simple)
Two column (simple, left sidebar)
Two column (simple, right sidebar)
Three column (simple)
Two column
Two column (left sidebar)
Two column (right sidebar)
Three column
Three column (left and right sidebars)
Undo
Redo
Find/Replace
Keyboard Shortcuts Help
<p>GroovySWT is <table class="wysiwyg-macro" data-macro-name="excerpt" data-macro-parameters="atlassian-macro-output-type=INLINE" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2V4Y2VycHQ6YXRsYXNzaWFuLW1hY3JvLW91dHB1dC10eXBlPUlOTElORX0&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="RICH_TEXT"><tr><td class="wysiwyg-macro-body"><p>a wrapper around SWT, the eclipse Standard Widget Toolkit</p></td></tr></table>. It allows you to easily write Eclipse <a href="http://www.eclipse.org/swt/">SWT</a> applications by using Groovy's <em>builder</em> mechanism.<br /> Here is some SWT code using native Groovy: <br class="atl-forced-newline" /></p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> import org.eclipse.swt.SWT import org.eclipse.swt.widgets.* import org.eclipse.swt.layout.RowLayout as Layout def display = new Display() def shell = new Shell(display) shell.layout = new Layout(SWT.VERTICAL) shell.text = 'Groovy / SWT Test' def label = new Label(shell, SWT.NONE) label.text = 'Simple demo of Groovy and SWT' shell.defaultButton = new Button(shell, SWT.PUSH) shell.defaultButton.text = ' Push Me ' shell.pack() shell.open() while (!shell.disposed) { if (!shell.display.readAndDispatch()) shell.display.sleep() } </pre></td></tr></table> <p>When you run this (see below for setup details), the result looks like:</p> <p><img class="confluence-embedded-image" src="/download/attachments/231080200/GroovySwtDemo.jpg?version=1&modificationDate=1369486943997" data-image-src="/download/attachments/231080200/GroovySwtDemo.jpg?version=1&modificationDate=1369486943997" data-linked-resource-id="231376137" data-linked-resource-type="attachment" data-linked-resource-default-alias="GroovySwtDemo.jpg" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080200" title="null > GroovySwtDemo.jpg"></p> <p>Here is the same example using SwtBuilder - note that this example does more because it actually prints some text 'Hello' to standard output when you press the button: <br class="atl-forced-newline" /></p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> import org.eclipse.swt.SWT import org.eclipse.swt.widgets.* def swt = new groovy.swt.SwtBuilder() def shell = swt.shell(text:'Groovy / SWT Test') { rowLayout() label('Simple demo of Groovy and SWT') button(' Push Me ') { onEvent(type:'Selection') { println "Hello" } } } shell.doMainloop() </pre></td></tr></table> <h3>Examples </h3> <p>For a short example of using the JFace builder for creating a standard application see the <a href="http://docs.codehaus.org/display/GROOVY/A+sample+application">TextEditor sample</a>.<br /> You can find about 70 examples in the example <a href="http://svn.groovy.codehaus.org/browse/groovy/trunk/groovy/modules/groovy-swt/src/examples/groovy">directory in subversion</a> or you can download them <a class="confluence-link unresolved" data-filename="groovy-swt-0.5-examples.zip" data-linked-resource-default-alias="groovy-swt-0.5-examples.zip" href="#">here</a>.</p> <p>For a comparison of the groovy and java code see <a href="http://docs.codehaus.org/display/GROOVY/groovy-swt+-+Comparing+the+java+and+the+groovy+code">here</a> or see the latest code in subversion.</p> <h3>Platform dependency.</h3> <p>Groovy-swt is not platform dependent, but SWT is. So you need to make sure that you are running a SWT matching the platform you are running the application on. You can download the appropriate SWT version at <a href="http://download.eclipse.org/eclipse/downloads/">eclipse</a> (select the eclipse version, find the heading "SWT Binary and Source", and download the SWT for your platform)</p> <h3>Releases:</h3> <p>See the <a href="http://docs.codehaus.org/display/GROOVY/Changelog">changelog</a> for changes.</p> <h4>0.5:</h4> <p>Updated to eclipse 3.5 (see the changelog for all the other changes)</p> <ul> <li>groovy-swt-0.5 with all eclipse libraries and the windows version of SWT: <a href="http://svn.groovy.codehaus.org/browse/~raw,r=16909/groovy/trunk/groovy/modules/groovy-swt/dist/groovy-swt-0.5-windows-all.jar">groovy-swt-0.5-windows-all.jar</a></li> <li>groovy-swt-0.5 with all eclipse libraries but no SWT: <a href="http://svn.groovy.codehaus.org/browse/~raw,r=16909/groovy/trunk/groovy/modules/groovy-swt/dist/groovy-swt-0.5-without-swt.jar">groovy-swt-0.5-without-swt.jar</a></li> <li>groovy-swt-0.5 examples: <a href="http://svn.groovy.codehaus.org/browse/~raw,r=16909/groovy/trunk/groovy/modules/groovy-swt/dist/groovy-swt-0.5-examples.zip">groovy-swt-0.5-examples.zip</a></li> </ul> <p>Please note the 0.5 was completely re-written to use FactoryBuilderSupport (to be able to be included in griffon), so there may be a few inconsistencies with version 0.3, but if you find any then please let me know. You can see the <a href="http://docs.codehaus.org/display/GROOVY/Changelog">changelog</a> for a list of all the changes.</p> <p>Another major new feature in version 0.5 is the binding framework (build on top of the jface databinding and following the same style as the swing builder). You can find a little documentation with examples <a href="http://docs.codehaus.org/display/GROOVY/Binding">here</a>.</p> <h4>0.3:</h4> <p>The sources (and README.txt telling you how to set up the libraries and dll's) can be found in subversion:</p> <ul class="alternate"> <li><a href="http://svn.groovy.codehaus.org/browse/groovy/trunk/groovy/modules/groovy-swt">groovy-swt</a></li> </ul> <p>The jar file compiled against Eclipse SDK 3.3 jars can be found attached:</p> <ul class="alternate"> <li><a href="http://docs.codehaus.org/download/attachments/17022/groovy-swt-0.3.jar">groovy-swt-0.3.jar</a></li> </ul> <p>To run groov-swt application you also need some of the eclipse libraries (including SWT), so download <a href="http://docs.codehaus.org/download/attachments/17022/groovy-swt-0.3-including-Eclipse-libs.ZIP+">groovy-swt-0.3-including-Eclipse-libs.ZIP</a> and unzip all the jar files into the lib directory of your groovy installation. This zip file includes the windows version of SWT, so if you are on another platform you need to download the appropriate version of SWT at <a href="http://www.eclipse.org/swt/">eclipse </a>and include that instead. <br class="atl-forced-newline" /></p>
Please type the word appearing in the picture.
Attachments
Labels
Location
Watch this page
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced