<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>xappworks</title>
	<atom:link href="http://xappworks.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://xappworks.com</link>
	<description></description>
	<lastBuildDate>Tue, 14 Jun 2011 21:45:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>First App Launched on Xappworks Platform</title>
		<link>http://xappworks.com/first-app-launched-on-xappworks-platform/</link>
		<comments>http://xappworks.com/first-app-launched-on-xappworks-platform/#comments</comments>
		<pubDate>Tue, 14 Jun 2011 21:03:45 +0000</pubDate>
		<dc:creator>fmiers</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Bug Tracking]]></category>
		<category><![CDATA[Cloud computing]]></category>
		<category><![CDATA[test management]]></category>

		<guid isPermaLink="false">http://xappworks.com/?p=560</guid>
		<description><![CDATA[Automation Consultants has launched <strong> </strong><a href="http://www.automation-consultants.com/view.php?cat=products&#38;article_id=224"><strong>TestWave</strong></a>, a test management tool, on the Xappworks platform.]]></description>
			<content:encoded><![CDATA[<p>Automation Consultants has launched<strong> </strong><a href="http://www.automation-consultants.com/view.php?cat=products&amp;article_id=224"><strong>TestWave</strong></a>, a test management tool, on the Xappworks platform. </p>
<p>Built by testers for testers, TestWave manages the testing of an IT system as part of a development project or a major change such as an upgrade to or a migration of a large system. TestWave permits teams of testers to work collaboratively, minimizing error and duplication, and it allows management to see progress at a glance.</p>
<p>To learn more, see <a href="http://www.automation-consultants.com/view.php?cat=products&amp;article_id=224">http://www.automation-consultants.com/view.php?cat=products&amp;article_id=224</a> .<br />
.</p>
]]></content:encoded>
			<wfw:commentRss>http://xappworks.com/first-app-launched-on-xappworks-platform/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Now Live: Java Library Upload!</title>
		<link>http://xappworks.com/now-live-java-library-upload/</link>
		<comments>http://xappworks.com/now-live-java-library-upload/#comments</comments>
		<pubDate>Sat, 15 Jan 2011 17:26:07 +0000</pubDate>
		<dc:creator>fmiers</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://xappworks.com/?p=548</guid>
		<description><![CDATA[This puts a massive base of existing Java code at the disposal of Xappworks users ]]></description>
			<content:encoded><![CDATA[<p>You can now upload Java libraries (jar files) to your Xappworks account and use them in any of your applications. Please see the <a title="help" href="http://www.xappworks.com/dokuwiki/doku.php?id=library_import" target="_blank">help</a> for an example. This puts a massive base of existing Java code at the disposal of Xappworks users and makes it easy to port  any given Java application into the cloud.</p>
<p>Once uploaded, the classes and methods in the Java Libraries can be called seamlessly from your Xappworks applications. You can instantiate the objects in the uploaded libraries and call their methods directly from your code modules.</p>
<p>In the case of a standalone Java application in the form of an executable jar file, you can import the jar file to a xappworks application, call its main() method with a single line of code and it will run.</p>
<p>Importing multiple libraries to a single application is not a problem. Xappworks ensures that they are all on the classpath and can reference each other.</p>
<p>For Java applications which access private resources such as a local network or a database, you will need to consider whether the connections to these resources will work from a Xappworks client. For example, if the resource is a database, and you wish it to be accessible from any Xappworks client on the internet, you could consider replacing it with a Xappworks cloud database. In this case, the parts of the code which access the database might have to be rewritten, but the rest of the code could be reused without change.</p>
]]></content:encoded>
			<wfw:commentRss>http://xappworks.com/now-live-java-library-upload/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Beta update</title>
		<link>http://xappworks.com/beta-update/</link>
		<comments>http://xappworks.com/beta-update/#comments</comments>
		<pubDate>Fri, 07 Jan 2011 09:32:09 +0000</pubDate>
		<dc:creator>Robert Limbrey</dc:creator>
				<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://xappworks.com/?p=537</guid>
		<description><![CDATA[The beta programme is going well &#8211; we have had lots of great feedback; and are well on track to be completing the beta phase sometime in Feb/March. Most of our glitches and fixes are already in place, and we are currently working on additional functionality including: import any java class &#8211; for greater java [...]]]></description>
			<content:encoded><![CDATA[<p>The beta programme is going well &#8211; we have had lots of great feedback; and are well on track to be completing the beta phase sometime in Feb/March.  Most of our glitches and fixes are already in place, and we are currently working on additional functionality including:</p>
<ul>
<li>import any java class &#8211; for greater java compatibility</li>
<li>a billing engine, so you can charge for your app</li>
<li>an appstore &#8211; so you can market your app</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://xappworks.com/beta-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Apps in Development!</title>
		<link>http://xappworks.com/new-apps-in-development/</link>
		<comments>http://xappworks.com/new-apps-in-development/#comments</comments>
		<pubDate>Fri, 07 Jan 2011 09:21:11 +0000</pubDate>
		<dc:creator>Robert Limbrey</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://xappworks.com/?p=533</guid>
		<description><![CDATA[We&#8217;re pleased to be monitoring the development of several new and exciting SaaS applications for the enterprise market. The first candidate is a test management tool &#8211; designed to provide support for those software testers who are struggling with managing large and complex testing cycles. The second candidate is a process management tool &#8211; for [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;re pleased to be monitoring the development of several new and exciting SaaS applications for the enterprise market.  The first candidate is a <strong>test management</strong> tool &#8211; designed to provide support for those software testers who are struggling with managing large and complex testing cycles.  The second candidate is a <strong>process management</strong> tool &#8211; for team leaders who are frustrated with managing large and fragmented teams, lack of process standardisation, and under pressure to deliver process improvements <em>(Ed: could be a six-sigma benefit here)</em>.</p>
<p>More app candidates are being registered every day.  Why not take a start at your own xappworks app?</p>
]]></content:encoded>
			<wfw:commentRss>http://xappworks.com/new-apps-in-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Welcome to Xappworks!</title>
		<link>http://xappworks.com/welcome-to-xappworks/</link>
		<comments>http://xappworks.com/welcome-to-xappworks/#comments</comments>
		<pubDate>Tue, 23 Nov 2010 16:42:24 +0000</pubDate>
		<dc:creator>Robert Limbrey</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://xappworks.com/?p=346</guid>
		<description><![CDATA[Welcome to the Xappworks community &#8211; now you&#8217;re ready to leverage the power of the web!  Take your business ideas, and create a Software-as-a-Service offering to generate a solid revenue stream! To get started, there are some excellent tutorials and helpful blog posts &#8211; and of course we will be creating more great content as [...]]]></description>
			<content:encoded><![CDATA[<p>Welcome to the Xappworks community &#8211; now you&#8217;re ready to leverage the power of the web!  Take your business ideas, and create a Software-as-a-Service offering to generate a solid revenue stream!</p>
<p>To get started, there are some excellent <a href="/category/tutorials" target="_self">tutorials</a> and helpful <a href="/category/blog" target="_self">blog posts</a> &#8211; and of course we will be creating more great content as we go.  If you&#8217;ve got any questions &#8211; don&#8217;t hold back from getting involved in our <a href="/wordpress/forum" target="_self">user forum</a>; or join our twitter feed <a href="http://twitter.com/xappworks" target="_self">@xappworks</a>.</p>
<p>Despite all that, make sure you register and start your own sandpit development environment.  Xappworks is based on the <a href="http://groovy.codehaus.org/" target="_self">Groovy </a>language (which is based on Java) &#8211; and we&#8217;re here to help you get started.  Let us know how we can do that better!</p>
]]></content:encoded>
			<wfw:commentRss>http://xappworks.com/welcome-to-xappworks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Xappworks Beta &#8211; launched for early adopters</title>
		<link>http://xappworks.com/xappworks-beta-launched-for-early-adopters/</link>
		<comments>http://xappworks.com/xappworks-beta-launched-for-early-adopters/#comments</comments>
		<pubDate>Tue, 23 Nov 2010 16:41:53 +0000</pubDate>
		<dc:creator>Robert Limbrey</dc:creator>
				<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://xappworks.com/?p=344</guid>
		<description><![CDATA[We at Xappworks are delighted to announce that our public beta for early adopters is now launched!  In this release, we have a fully-fledged Groovy development and runtime environment in the cloud, help and tutorials to help you get started, and a fledgling community where you can share ideas. There are plenty of new things [...]]]></description>
			<content:encoded><![CDATA[<p>We at Xappworks are delighted to announce that our public beta for early adopters is now launched!  In this release, we have a fully-fledged Groovy development and runtime environment in the cloud, help and tutorials to help you get started, and a fledgling community where you can share ideas.</p>
<p>There are plenty of new things we&#8217;re working on, including an application marketplace and a billing engine &#8211; so you can generate your SaaS revenues.  Please be patient with us as we get all the ingredients ready for a successful launch in early 2011!!</p>
]]></content:encoded>
			<wfw:commentRss>http://xappworks.com/xappworks-beta-launched-for-early-adopters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get Started Now</title>
		<link>http://xappworks.com/sign-up-now/</link>
		<comments>http://xappworks.com/sign-up-now/#comments</comments>
		<pubDate>Tue, 23 Nov 2010 14:50:30 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Homepage]]></category>

		<guid isPermaLink="false">http://xappworks.com/?p=332</guid>
		<description><![CDATA[<p><table border=0 style="margin:0px 0 0 10px;padding:0;"><tr><td><a  href="http://xappworks.com/go/"  onmouseover="buttondown('startXappworks')" onmouseout="buttonup('startXappworks')"><img style="padding:0px; margin:2px 0 0 0;" src="http://xappworks.com/wp-content/uploads/2010/11/startButton.png" name="startXappworks" border="0" /></a></td></tr>
<tr><td><p>Don't have an account yet? </p></td></tr><tr><td><a href="http://xappworks.com/wp-login.php?action=register"><img src="http://xappworks.com/wp-content/themes/xappworks/images/join.png" style="padding:0px; margin:2px 0 0 0;"></img></a></td></tr></table></p>]]></description>
			<content:encoded><![CDATA[<p><table border=0 style="margin:0px 0 0 10px;padding:0;"><tr><td><a  href="http://xappworks.com/go/"  onmouseover="buttondown('startXappworks')" onmouseout="buttonup('startXappworks')"><img style="padding:0px; margin:2px 0 0 0;" src="http://xappworks.com/wp-content/uploads/2010/11/startButton.png" name="startXappworks" border="0" /></a></td></tr>
<tr><td><p>Don't have an account yet? </p></td></tr><tr><td><a href="http://xappworks.com/wp-login.php?action=register"><img src="http://xappworks.com/wp-content/themes/xappworks/images/join.png" style="padding:0px; margin:2px 0 0 0;"></img></a></td></tr></table></p>]]></content:encoded>
			<wfw:commentRss>http://xappworks.com/sign-up-now/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using SwingBuilder</title>
		<link>http://xappworks.com/using-swingbuilder/</link>
		<comments>http://xappworks.com/using-swingbuilder/#comments</comments>
		<pubDate>Wed, 22 Sep 2010 16:12:54 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://xappworks.com/?p=98</guid>
		<description><![CDATA[Creating GUIs with groovy is pretty easy once you learn to use the SwingBuilder. Builders in groovy allow you to work in a declarative way similar to say, HTML. This has the benefit of making your code more readable and easier to maintain. In this short tutorial we&#8217;re going to create a basic calculator using [...]]]></description>
			<content:encoded><![CDATA[<p>Creating GUIs with groovy is pretty easy once you learn to use the SwingBuilder. Builders in groovy allow you to work in a declarative way similar to say, HTML. This has the benefit of making your code more readable and easier to maintain. In this short tutorial we&#8217;re going to create a basic calculator using the SwingBuilder. We&#8217;ll also touch on laying out components with layout managers and how to handle events. Please note this tutorial would also work for regular groovy outside of Xappworks.</p>
<div id="attachment_111" class="wp-caption aligncenter" style="width: 341px"><a href="http://xappworks.com/wp-content/uploads/2010/09/Screenshot-XCalc.png"><img class="size-full wp-image-111" title="Screenshot-XCalc" src="http://xappworks.com/wp-content/uploads/2010/09/Screenshot-XCalc.png" alt="The Calculator We're Making" width="331" height="174" /></a><p class="wp-caption-text">The calculator we&#39;re making in this tutorial</p></div>
<p>To get started create a new project called &#8220;CalcTutorial&#8221;. (If you need a reminder for this have a look in the <a href="http://xappworks.com/?p=80">Hello World Tutorial</a>).</p>
<p>In our new project we want to create a new class called Calc (File&gt;New&gt; Module). Your new file should look like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Calc<span style="color: #66cc66;">&#123;</span>
 <span style="color: #000000; font-weight: bold;">public</span> Calc<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
 <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>The first thing we want to do is tell the compiler that we want access to some extra libraries, this is done by using the import statement at the top of your class file like so:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">java.awt.*</span><span style="color: #66cc66;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">javax.swing.*</span><span style="color: #66cc66;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">groovy.swing.*</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Calc<span style="color: #66cc66;">&#123;</span>
 <span style="color: #000000; font-weight: bold;">public</span> Calc<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
 <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>These 3 are important as they provide access to Swing, the GUI toolkit we&#8217;ll be using;AWT, upon which Swing is built; and Groovy&#8217;s SwingBuilder. You find out more about these by following the links at the bottom.</p>
<p>Now that we have our imports in place, we want to create a SwingBuilder object that we can use to create our form. Create a varible called sb at the class level (between lines 5 and 6) like so:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>6
7
8
9
10
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Calc<span style="color: #66cc66;">&#123;</span>
 <span style="color: #000000; font-weight: bold;">def</span> sb <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SwingBuilder<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
 <span style="color: #000000; font-weight: bold;">public</span> Calc<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
 <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>Now we can make use of the SwingBuilder within our constructor. If you&#8217;re new to Groovy or Java a constructor is the first piece of code called in a class when it is instantiated (when the &#8220;new&#8221; keyword is used). The first thing we want to do with our SwingBuilder is create a new window; in swing this is called a JFrame. Most swing components class names actually start with the letter J  but the SwingBuilder has removed the need for that since we know we&#8217;re working with swing.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>7
8
9
10
11
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">def</span> sb <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SwingBuilder<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #000000; font-weight: bold;">public</span> Calc<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
	sb.<span style="color: #006600;">frame</span><span style="color: #66cc66;">&#40;</span>id:<span style="color: #ff0000;">&quot;calcFrame&quot;</span>,title:<span style="color: #ff0000;">&quot;XCalc&quot;</span>,<span style="color: #663399;">size</span>:<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">300</span>,<span style="color: #cc66cc;">200</span><span style="color: #66cc66;">&#93;</span>, visible:<span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
        <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>You&#8217;ll notice that we are setting several properties in the new line we added such as an id, a title, a size and that the form should be visible. We want to be able to run this to see how it looks so open up Main.mod and make it look like the following:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Main<span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #993333;">void</span> main<span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">String</span> <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> args<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">new</span> Calc<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>Press the save all button, then press the run button. You should see a blank form appear:</p>
<div id="attachment_119" class="wp-caption alignnone" style="width: 310px"><a href="http://xappworks.com/wp-content/uploads/2010/09/Screenshot-XCalc-1.png"><img class="size-full wp-image-119" title="Screenshot-XCalc-1" src="http://xappworks.com/wp-content/uploads/2010/09/Screenshot-XCalc-1.png" alt="A blank form" width="300" height="200" /></a><p class="wp-caption-text">A blank form</p></div>
<p>When designing  a gui, it helps to split it up into smaller areas that can have different layout, for example a calculator has a display area and an input area and so we&#8217;ll use something called the BorderLayout which we can use to specify these two areas. BorderLayout actually lets you position components in compass directions: North, South, East, West and Center. In our case we want to split our form up like the picture below:</p>
<div id="attachment_123" class="wp-caption alignnone" style="width: 341px"><a href="http://xappworks.com/wp-content/uploads/2010/09/Screenshot-XCalcAreas.png"><img class="size-full wp-image-123" title="Screenshot-XCalcAreas" src="http://xappworks.com/wp-content/uploads/2010/09/Screenshot-XCalcAreas.png" alt="Splitting our form up" width="331" height="174" /></a><p class="wp-caption-text">Splitting our form up</p></div>
<p>So how do we create these areas? Well we do it by firstly telling the SwingBuilder what sort of layout we want and then using the constraints poperites of our components to tell them where to go:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;">sb.<span style="color: #006600;">frame</span><span style="color: #66cc66;">&#40;</span>id:<span style="color: #ff0000;">&quot;calcFrame&quot;</span>,title:<span style="color: #ff0000;">&quot;XCalc&quot;</span>,<span style="color: #663399;">size</span>:<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">300</span>,<span style="color: #cc66cc;">200</span><span style="color: #66cc66;">&#93;</span>, visible:<span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
   borderLayout<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
   textField<span style="color: #66cc66;">&#40;</span>id:<span style="color: #ff0000;">&quot;display&quot;</span>,editable:<span style="color: #000000; font-weight: bold;">false</span>,horizontalAlignment: <span style="color: #aaaadd; font-weight: bold;">JTextField</span>.<span style="color: #006600;">RIGHT</span>,constraints:<span style="color: #aaaadd; font-weight: bold;">BorderLayout</span>.<span style="color: #006600;">NORTH</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
   panel<span style="color: #66cc66;">&#40;</span>id:<span style="color: #ff0000;">&quot;buttons&quot;</span>, constraints:<span style="color: #aaaadd; font-weight: bold;">BorderLayout</span>.<span style="color: #006600;">CENTER</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
   <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
sb.<span style="color: #006600;">calcFrame</span>.<span style="color: #006600;">pack</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span></pre></td></tr></table></div>

<p>You can see we&#8217;ve added two components now: a textfield for displaying our numbers and a panel for holding all of our buttons. We also added a line that tells the frame to pack. This means that it&#8217;ll shrink to fit the components within it. One thing you might be thinking is that there are more buttons on a calculator than compass directions, so how are we going to lay them out in a grid? Well this is where we make use of another layout called GridLayout. When you create a gridlayout you can set how many rows and columns you want to use, and the gaps between the grid cells. We want 4 columns and 5 rows for our calculator so we do the following:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;">panel<span style="color: #66cc66;">&#40;</span>id:<span style="color: #ff0000;">&quot;buttons&quot;</span>, constraints:<span style="color: #aaaadd; font-weight: bold;">BorderLayout</span>.<span style="color: #006600;">CENTER</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
       gridLayout<span style="color: #66cc66;">&#40;</span>cols:<span style="color: #cc66cc;">4</span>, rows:<span style="color: #cc66cc;">5</span>, hgap:<span style="color: #cc66cc;">1</span>, vgap:<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><br />
Once you&#8217;ve done that it&#8217;s time to add the buttons:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;">panel<span style="color: #66cc66;">&#40;</span>id:<span style="color: #ff0000;">&quot;buttons&quot;</span>, constraints:<span style="color: #aaaadd; font-weight: bold;">BorderLayout</span>.<span style="color: #006600;">CENTER</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
        gridLayout<span style="color: #66cc66;">&#40;</span>cols:<span style="color: #cc66cc;">4</span>, rows:<span style="color: #cc66cc;">5</span>, hgap:<span style="color: #cc66cc;">1</span>, vgap:<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
	button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;Bksp&quot;</span>, actionPerformed:<span style="color: #66cc66;">&#123;</span>backSpace<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
	button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;Clr&quot;</span>, actionPerformed:<span style="color: #66cc66;">&#123;</span>clear<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
	label<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span>
	label<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
	button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;7&quot;</span><span style="color: #66cc66;">&#41;</span>
	button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;8&quot;</span><span style="color: #66cc66;">&#41;</span>
	button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;9&quot;</span><span style="color: #66cc66;">&#41;</span>
	button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;/&quot;</span><span style="color: #66cc66;">&#41;</span> 
&nbsp;
	button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;4&quot;</span><span style="color: #66cc66;">&#41;</span>
	button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;5&quot;</span><span style="color: #66cc66;">&#41;</span>
	button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;6&quot;</span><span style="color: #66cc66;">&#41;</span>
	button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;*&quot;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
	button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #66cc66;">&#41;</span>
	button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;2&quot;</span><span style="color: #66cc66;">&#41;</span>
	button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;3&quot;</span><span style="color: #66cc66;">&#41;</span>
	button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;-&quot;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
	button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #66cc66;">&#41;</span>
	button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;.&quot;</span><span style="color: #66cc66;">&#41;</span>
	button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;=&quot;</span><span style="color: #66cc66;">&#41;</span>
	button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;+&quot;</span><span style="color: #66cc66;">&#41;</span>					
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>If you run this you should see something that looks like the calculator picture at the start. But a calulator that doens&#8217;t do anything isn&#8217;t very interesting so we&#8217;re going to need to add some event handlers and something to process the calculator. Before we go on you&#8217;re code should look like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">java.awt.*</span><span style="color: #66cc66;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">javax.swing.*</span><span style="color: #66cc66;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">groovy.swing.*</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Calc<span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">def</span> sb <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SwingBuilder<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> Calc<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
&nbsp;
		sb.<span style="color: #006600;">frame</span><span style="color: #66cc66;">&#40;</span>id:<span style="color: #ff0000;">&quot;calcFrame&quot;</span>,title:<span style="color: #ff0000;">&quot;XCalc&quot;</span>, visible:<span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
                        borderLayout<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
			textField<span style="color: #66cc66;">&#40;</span>id:<span style="color: #ff0000;">&quot;display&quot;</span>, editable:<span style="color: #000000; font-weight: bold;">false</span>,horizontalAlignment: <span style="color: #aaaadd; font-weight: bold;">JTextField</span>.<span style="color: #006600;">RIGHT</span>,constraints:<span style="color: #aaaadd; font-weight: bold;">BorderLayout</span>.<span style="color: #006600;">NORTH</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
			panel<span style="color: #66cc66;">&#40;</span>id:<span style="color: #ff0000;">&quot;buttons&quot;</span>, constraints:<span style="color: #aaaadd; font-weight: bold;">BorderLayout</span>.<span style="color: #006600;">CENTER</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
				gridLayout<span style="color: #66cc66;">&#40;</span>cols:<span style="color: #cc66cc;">4</span>, rows:<span style="color: #cc66cc;">5</span>, hgap:<span style="color: #cc66cc;">1</span>, vgap:<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;Bksp&quot;</span>, actionPerformed:<span style="color: #66cc66;">&#123;</span>backSpace<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;Clr&quot;</span>, actionPerformed:<span style="color: #66cc66;">&#123;</span>clear<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
				label<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span>
				label<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;7&quot;</span><span style="color: #66cc66;">&#41;</span>
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;8&quot;</span><span style="color: #66cc66;">&#41;</span>
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;9&quot;</span><span style="color: #66cc66;">&#41;</span>
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;/&quot;</span><span style="color: #66cc66;">&#41;</span> 
&nbsp;
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;4&quot;</span><span style="color: #66cc66;">&#41;</span>
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;5&quot;</span><span style="color: #66cc66;">&#41;</span>
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;6&quot;</span><span style="color: #66cc66;">&#41;</span>
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;*&quot;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #66cc66;">&#41;</span>
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;2&quot;</span><span style="color: #66cc66;">&#41;</span>
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;3&quot;</span><span style="color: #66cc66;">&#41;</span>
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;-&quot;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #66cc66;">&#41;</span>
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;.&quot;</span><span style="color: #66cc66;">&#41;</span>
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;=&quot;</span><span style="color: #66cc66;">&#41;</span>
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;+&quot;</span><span style="color: #66cc66;">&#41;</span>					
&nbsp;
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #66cc66;">&#125;</span>
		sb.<span style="color: #006600;">calcFrame</span>.<span style="color: #006600;">pack</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>First things first we want to create a method to handle our button presses, this will be called by all the buttons except &#8220;=&#8221;, &#8220;Bksp&#8221; and &#8220;Clr&#8221;. We&#8217;ll call this method insertText since it&#8217;ll be adding text to the display area, add it below the constructor at around line 47.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>46
47
48
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> insertText<span style="color: #66cc66;">&#40;</span>text<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
	sb.<span style="color: #006600;">display</span>.<span style="color: #006600;">text</span> <span style="color: #66cc66;">=</span>sb.<span style="color: #006600;">display</span>.<span style="color: #006600;">text</span> <span style="color: #66cc66;">+</span> text
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>As you can see the method takes a parameter called text, this will be the text from our button (the number or the operator we want to add to the display). We get a hold of our display textfield using it&#8217;s id from the swing builder <tt>sb.display</tt> and we want to set its text property equal to what it currently is plus the text parameter the method takes. Now that we have our handler we can tell the buttons to use it:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>21
22
23
24
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;">        button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;7&quot;</span>,actionPerformed:<span style="color: #66cc66;">&#123;</span>insertText<span style="color: #66cc66;">&#40;</span>it.<span style="color: #006600;">source</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
	button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;8&quot;</span>,actionPerformed:<span style="color: #66cc66;">&#123;</span>insertText<span style="color: #66cc66;">&#40;</span>it.<span style="color: #006600;">source</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
	button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;9&quot;</span>,actionPerformed:<span style="color: #66cc66;">&#123;</span>insertText<span style="color: #66cc66;">&#40;</span>it.<span style="color: #006600;">source</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
	button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;/&quot;</span>,actionPerformed:<span style="color: #66cc66;">&#123;</span>insertText<span style="color: #66cc66;">&#40;</span>it.<span style="color: #006600;">source</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span></pre></td></tr></table></div>

<p>You see that we use actionPerformed to call our method passing it the text of the button: <tt>it.source.text</tt>. Add this for all the buttons except  &#8220;=&#8221;, &#8220;Bksp&#8221; and &#8220;Clr&#8221; since they do very different things. We&#8217;ll handle the clear button next:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>51
52
53
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> clear<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
	sb.<span style="color: #006600;">display</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>16
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;">      button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;Clr&quot;</span>, actionPerformed:<span style="color: #66cc66;">&#123;</span>clear<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span></pre></td></tr></table></div>

<p>Now for backspace:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>55
56
57
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> backspace<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
	sb.<span style="color: #006600;">display</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">=</span>sb.<span style="color: #006600;">display</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span>..<span style="color: #006600;">sb</span>.<span style="color: #006600;">display</span>.<span style="color: #006600;">text</span>.<span style="color: #006600;">length</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">-</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>16
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;">      button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;Bksp&quot;</span>, actionPerformed:<span style="color: #66cc66;">&#123;</span>backspace<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span></pre></td></tr></table></div>

<p>And last but not least the method to perform our calculation:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>59
60
61
62
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> doEquals<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
	GroovyShell shell <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GroovyShell<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
	sb.<span style="color: #006600;">display</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">=</span>shell.<span style="color: #006600;">evaluate</span><span style="color: #66cc66;">&#40;</span>sb.<span style="color: #006600;">display</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>38
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;">       	button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;=&quot;</span>,actionPerformed:<span style="color: #66cc66;">&#123;</span>doEquals<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span></pre></td></tr></table></div>

<p>Press save all and then run the application. You should now have a fully working calculator! </p>
<p>You&#8217;re finished code should look like the following:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">groovy.swing.*</span><span style="color: #66cc66;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">java.awt.*</span><span style="color: #66cc66;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">javax.swing.*</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Calc<span style="color: #66cc66;">&#123;</span> 
	<span style="color: #000000; font-weight: bold;">def</span> sb <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SwingBuilder<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> Calc<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
&nbsp;
		sb.<span style="color: #006600;">frame</span><span style="color: #66cc66;">&#40;</span>id:<span style="color: #ff0000;">&quot;calcFrame&quot;</span>,title:<span style="color: #ff0000;">&quot;XCalc&quot;</span>,<span style="color: #663399;">size</span>:<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">300</span>,<span style="color: #cc66cc;">200</span><span style="color: #66cc66;">&#93;</span>, visible:<span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
			borderLayout<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
			textField<span style="color: #66cc66;">&#40;</span>id:<span style="color: #ff0000;">&quot;display&quot;</span>, editable:<span style="color: #000000; font-weight: bold;">false</span>,horizontalAlignment: <span style="color: #aaaadd; font-weight: bold;">JTextField</span>.<span style="color: #006600;">RIGHT</span>,constraints:<span style="color: #aaaadd; font-weight: bold;">BorderLayout</span>.<span style="color: #006600;">NORTH</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
			panel<span style="color: #66cc66;">&#40;</span>constraints:<span style="color: #aaaadd; font-weight: bold;">BorderLayout</span>.<span style="color: #006600;">CENTER</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
				gridLayout<span style="color: #66cc66;">&#40;</span>cols:<span style="color: #cc66cc;">4</span>, rows:<span style="color: #cc66cc;">5</span>, hgap:<span style="color: #cc66cc;">1</span>, vgap:<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;Bksp&quot;</span>, actionPerformed:<span style="color: #66cc66;">&#123;</span>backSpace<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;Clr&quot;</span>, actionPerformed:<span style="color: #66cc66;">&#123;</span>clear<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
				label<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span>
				label<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;7&quot;</span>,actionPerformed:<span style="color: #66cc66;">&#123;</span>insertText<span style="color: #66cc66;">&#40;</span>it.<span style="color: #006600;">source</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;8&quot;</span>,actionPerformed:<span style="color: #66cc66;">&#123;</span>insertText<span style="color: #66cc66;">&#40;</span>it.<span style="color: #006600;">source</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;9&quot;</span>, actionPerformed:<span style="color: #66cc66;">&#123;</span>insertText<span style="color: #66cc66;">&#40;</span>it.<span style="color: #006600;">source</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;/&quot;</span>,actionPerformed:<span style="color: #66cc66;">&#123;</span>insertText<span style="color: #66cc66;">&#40;</span>it.<span style="color: #006600;">source</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span> 
&nbsp;
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;4&quot;</span>,actionPerformed:<span style="color: #66cc66;">&#123;</span>insertText<span style="color: #66cc66;">&#40;</span>it.<span style="color: #006600;">source</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;5&quot;</span>,actionPerformed:<span style="color: #66cc66;">&#123;</span>insertText<span style="color: #66cc66;">&#40;</span>it.<span style="color: #006600;">source</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;6&quot;</span>,actionPerformed:<span style="color: #66cc66;">&#123;</span>insertText<span style="color: #66cc66;">&#40;</span>it.<span style="color: #006600;">source</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;*&quot;</span>,actionPerformed:<span style="color: #66cc66;">&#123;</span>insertText<span style="color: #66cc66;">&#40;</span>it.<span style="color: #006600;">source</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;1&quot;</span>,actionPerformed:<span style="color: #66cc66;">&#123;</span>insertText<span style="color: #66cc66;">&#40;</span>it.<span style="color: #006600;">source</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;2&quot;</span>,actionPerformed:<span style="color: #66cc66;">&#123;</span>insertText<span style="color: #66cc66;">&#40;</span>it.<span style="color: #006600;">source</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;3&quot;</span>,actionPerformed:<span style="color: #66cc66;">&#123;</span>insertText<span style="color: #66cc66;">&#40;</span>it.<span style="color: #006600;">source</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;-&quot;</span>,actionPerformed:<span style="color: #66cc66;">&#123;</span>insertText<span style="color: #66cc66;">&#40;</span>it.<span style="color: #006600;">source</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;0&quot;</span>,actionPerformed:<span style="color: #66cc66;">&#123;</span>insertText<span style="color: #66cc66;">&#40;</span>it.<span style="color: #006600;">source</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;.&quot;</span>,actionPerformed:<span style="color: #66cc66;">&#123;</span>insertText<span style="color: #66cc66;">&#40;</span>it.<span style="color: #006600;">source</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;=&quot;</span>,actionPerformed:<span style="color: #66cc66;">&#123;</span>doEquals<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
				button<span style="color: #66cc66;">&#40;</span>text:<span style="color: #ff0000;">&quot;+&quot;</span>,actionPerformed:<span style="color: #66cc66;">&#123;</span>insertText<span style="color: #66cc66;">&#40;</span>it.<span style="color: #006600;">source</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>					
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #66cc66;">&#125;</span>
		sb.<span style="color: #006600;">calcFrame</span>.<span style="color: #006600;">pack</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> insertText<span style="color: #66cc66;">&#40;</span>text<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
		sb.<span style="color: #006600;">display</span>.<span style="color: #006600;">text</span> <span style="color: #66cc66;">=</span>sb.<span style="color: #006600;">display</span>.<span style="color: #006600;">text</span> <span style="color: #66cc66;">+</span> text
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> clear<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
		sb.<span style="color: #006600;">display</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> backSpace<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
		sb.<span style="color: #006600;">display</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">=</span>sb.<span style="color: #006600;">display</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span>..<span style="color: #006600;">sb</span>.<span style="color: #006600;">display</span>.<span style="color: #006600;">text</span>.<span style="color: #006600;">length</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">-</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>	
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> doEquals<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
		GroovyShell shell <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GroovyShell<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
		sb.<span style="color: #006600;">display</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">=</span>shell.<span style="color: #006600;">evaluate</span><span style="color: #66cc66;">&#40;</span>sb.<span style="color: #006600;">display</span>.<span style="color: #006600;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<h2>Useful Links</h2>
<ul>
<li><a href="http://xappworks.com/?p=80">Xappworks Hello World</a></li>
<li><a href="http://download.oracle.com/javase/tutorial/uiswing/layout/border.html">BorderLayout</a></li>
<li><a href="http://download.oracle.com/javase/tutorial/uiswing/layout/grid.html">GridLayout</a></li>
<li><a href="http://groovy.codehaus.org/GUI+Programming+with+Groovy">GUI Programming with Groovy</a></li>
<li><a href="http://groovy.codehaus.org/Swing+Builder">Swing Builder</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://xappworks.com/using-swingbuilder/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Getting Started (aka Hello World)</title>
		<link>http://xappworks.com/getting-started-aka-hello-world/</link>
		<comments>http://xappworks.com/getting-started-aka-hello-world/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 16:40:03 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://xappworks.com/?p=80</guid>
		<description><![CDATA[You&#8217;ve decided to you want to know more about Xappworks and signed up for early access, but where do you go from there? Well let&#8217;s start by creating our first application! When you first login you&#8217;ll be presented with the home screen, this is where you&#8217;ll navigate around your applications. If you haven&#8217;t done so [...]]]></description>
			<content:encoded><![CDATA[<p>You&#8217;ve decided to you want to know more about Xappworks and signed up for early access, but where do you go from there? Well let&#8217;s start by creating our first application!</p>
<p>When you first login you&#8217;ll be presented with the home screen, this is where you&#8217;ll navigate around your applications.</p>
<div id="attachment_82" class="wp-caption aligncenter" style="width: 372px"><a href="http://xappworks.com/wp-content/uploads/2010/08/tut1.png"><img class="size-full wp-image-82    " title="Home Screen" src="http://xappworks.com/wp-content/uploads/2010/08/tut1.png" alt="Home Screen" width="362" height="220" /></a><p class="wp-caption-text">The Home Screen</p></div>
<p>If you haven&#8217;t done so already you&#8217;ll want to create a new folder for your applications by clicking on the Object menu then pointing to New&gt; Folder and give it a name you like, then create the new applications by going to Object then New &gt; Application and give it a name.</p>
<p>Now click the folder you just made in the tree and you should see your application appear in the area on the right. If you right click on the icon a popup will appear to giving you the options to Run, Modify or Properites. We want to select Modify!</p>
<p><strong>The IDE</strong></p>
<p>Xappworks includes a built in IDE for creating your own applications which includes a text editor, form designer and database tools. When you open your new application it will look like this:</p>
<div id="attachment_84" class="wp-caption aligncenter" style="width: 380px"><a href="http://xappworks.com/wp-content/uploads/2010/08/Tut2.png"><img class="size-full wp-image-84" title="The IDE" src="http://xappworks.com/wp-content/uploads/2010/08/Tut2.png" alt="The IDE" width="370" height="209" /></a><p class="wp-caption-text">The IDE</p></div>
<p style="text-align: left;">Let&#8217;s edit the default Form1.frm by double clicking on it. The default size is a little big so shrink it by dragging from the edges inward. Drag a button from the palette on the left and place it on the middle of your form. Use the properties table on the right below the panel to name the button &#8220;helloBtn&#8221; and give it the text or label &#8220;Click Me&#8221;.</p>
<p style="text-align: left;">Drag a textfield from the palette onto the form and place it above the button and size it up so that your form looks like this:</p>
<p style="text-align: center;">
<div id="attachment_89" class="wp-caption aligncenter" style="width: 459px"><a href="http://xappworks.com/wp-content/uploads/2010/08/tut32.png"><img class="size-full wp-image-89  " title="Our First Form" src="http://xappworks.com/wp-content/uploads/2010/08/tut32.png" alt="Our First Form" width="449" height="214" /></a><p class="wp-caption-text">Our First Form</p></div>
<p style="text-align: left;">
<p style="text-align: left;">Call your textfield &#8220;helloTxt&#8221;, then select your button, click on the Events Tab by the properties and then edit the value for action event by double clicking and either give your event handler a name or just hit enter and it&#8217;ll be given a default name.</p>
<p style="text-align: left;">The code editor should appear now for Form1Module.mod. This file is used to handle all the logic behind your form. The first method is the constructor which is called just after the form has loaded, the second method is our new event handler. If you&#8217;ve gone for the default event name it&#8217;ll be called helloBtnactionEvent(event).</p>
<p style="text-align: left;">Between the two curly brackets (braces { } ) we&#8217;re going to add some code to make our form do something.</p>
<pre style="text-align: left; padding-left: 30px;">public void helloBtnactionEvent(event){
        myForm.helloTxt.text = "Hello, World " +  new Date();
        myForm.title ="My First App!!"
        myForm.form.background = java.awt.Color.blue;
}</pre>
<p style="text-align: left;">What this does is sets the text of our textfield to &#8220;Hello, World&#8221; and the current date and time, sets the title of the window to &#8220;My First App!!&#8221; and lastly, sets the forms background color to blue.</p>
<p style="text-align: left;">Hit the save all button in the toolbar (<a href="http://xappworks.com/wp-content/uploads/2010/08/disk_multiple.png"><img class="alignnone size-full wp-image-87" title="disk_multiple" src="http://xappworks.com/wp-content/uploads/2010/08/disk_multiple.png" alt="Save All Icon in toolbar" width="16" height="16" /></a>). Then press the green run button in the toolbar (<a href="http://xappworks.com/wp-content/uploads/2010/08/green_run.png"><img class="alignnone size-full wp-image-88" title="green_run" src="http://xappworks.com/wp-content/uploads/2010/08/green_run.png" alt="Green Run Button" width="16" height="16" /></a>).</p>
<p style="text-align: left;">That&#8217;s all for now have fun and if you have any issues let us know in the forums!</p>
<p style="text-align: left;">
]]></content:encoded>
			<wfw:commentRss>http://xappworks.com/getting-started-aka-hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

