<?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>The Kaptain on ... stuff &#187; SwingX</title>
	<atom:link href="http://www.kellyrob99.com/blog/tag/swingx/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kellyrob99.com/blog</link>
	<description>Tales of development, life and the folly that goes along with both</description>
	<lastBuildDate>Sun, 04 Dec 2011 21:51:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>More Groovy/Griffon/FEST Testing</title>
		<link>http://www.kellyrob99.com/blog/2009/04/10/more-griffonfest-testing/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=more-griffonfest-testing</link>
		<comments>http://www.kellyrob99.com/blog/2009/04/10/more-griffonfest-testing/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 19:47:23 +0000</pubDate>
		<dc:creator>TheKaptain</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Griffon]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[JXBusyLabel]]></category>
		<category><![CDATA[JXColorSelectionButton]]></category>
		<category><![CDATA[Model–view–controller]]></category>
		<category><![CDATA[Swing]]></category>
		<category><![CDATA[SwingBuilder]]></category>
		<category><![CDATA[SwingX]]></category>
		<category><![CDATA[TestNG]]></category>

		<guid isPermaLink="false">http://www.kellyrob99.com/blog/?p=261</guid>
		<description><![CDATA[In my continuing exploration of FEST testing using Groovy and the Griffon framework, I&#8217;ve added some tests for the ability to change the JXBusyLabel coloration on the fly. Since FEST allows you to alter the properties of the widgets directly, I didn&#8217;t have to do anything special to trigger actions on the JXColorSelectionButton. At first [...]
Related posts:<ol>
<li><a href='http://www.kellyrob99.com/blog/2009/04/08/griffon-swingx-fest-testing/' rel='bookmark' title='Griffon SwingX Fest testing'>Griffon SwingX Fest testing</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/04/05/swingx-busy-label-demo-in-griffon/' rel='bookmark' title='SwingX busy label demo in Griffon and Groovy'>SwingX busy label demo in Griffon and Groovy</a></li>
<li><a href='http://www.kellyrob99.com/blog/2010/02/11/a-one-day-griffon-applicationpresentation/' rel='bookmark' title='A One Day Griffon Application/Presentation'>A One Day Griffon Application/Presentation</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>In my continuing exploration of FEST testing using Groovy and the Griffon framework, I&#8217;ve added some tests for the ability to change the JXBusyLabel coloration on the fly.</p>
<p>Since FEST allows you to alter the properties of the widgets directly, I didn&#8217;t have to do anything special to trigger actions on the JXColorSelectionButton. At first look, I thought that specifying mouse click point locations would be necessary, but after digging a(very little) bit I discoveregroovyd that FEST exposes the underlying Component its&#8217; Fixture classes wrap as an internal &#8216;target&#8217;. Simply grabbing that Component and settings the background color directly was sufficient.<br />
Here is the new definition of the JXBusyLabel and the 3 buttons which controls its color changes. You can see that two of the three color changes happen automagically due to Groovy binding &#8211; setting the background color of the label didn&#8217;t appear to work for some reason that I have yet to puzzle out, so it gets a PropertyChangeListener &#8216;old school style&#8217;.</p>
<pre class="brush: groovy; smart-tabs: true; title: ; notranslate">
baseColBtn = colorButton(name: 'baseColBtn', background: model.baseColor)
highColBtn = colorButton(name: 'highColBtn', background: model.busyColor)
backColBtn = colorButton(name: 'backColBtn', background: PaintUtils.BLUE_EXPERIENCE.getColor1())
backColBtn.addPropertyChangeListener(&quot;background&quot;, {PropertyChangeEvent evt -&gt;
      label.setBackground((Color) evt.getNewValue())
      label.setOpaque(true)
} as PropertyChangeListener)

label = jxbusyLabel(name: 'busyLabel',
      preferredSize: new Dimension(model.W / 2 as int, model.H / 2 as int),
      busyPainter: busyPainter(
      highlightColor: bind { highColBtn.background }, baseColor: bind {baseColBtn.background},
      points: bind {slider.value}, trailLength: bind {tSlider.value}),
      opaque: false,
      horizontalAlignment: JLabel.CENTER,
      delay: bind {speedSlider.value},
      background: bind{backColBtn.background})
</pre>
<p>The three associated tests are essentially using the same recipe, so here&#8217;s just one of them to give you the idea.</p>
<pre class="brush: groovy; smart-tabs: true; title: ; notranslate">
 /**
 * Test that changing the 'baseColBtn' background color simultaneously
 * changes the busy label's base color.
 */
 @Test void testBaseColorChange() {
       startAnimation()
       def button = window.button('baseColBtn')
       def busyLabel = findBusyLabel()
       Color start = button.target.background
       Color busyStart = busyLabel.busyPainter.baseColor
       Assert.assertEquals(busyStart, start)

       button.target.background = Color.RED

       Assert.assertFalse(button.target.background == start)
       Assert.assertFalse(busyLabel.busyPainter.baseColor == busyStart)
       Assert.assertEquals(busyLabel.busyPainter.baseColor, Color.RED)
 }
</pre>
<p>Running the test suite takes less than a minute, and most of that time is spend dragging sliders. Those tests are presently going through the entire range of the slider, which is reassuring when actually watching the tests run, but probably overkill in terms of testing.  Considering that, running the test suite is pretty painless and quick(the new tests execute in &lt; 1s for instance). And of course the test results are available in the standard, pleasing, and hopefully all green, TestNG output. Which has, by the way, just <a href="http://beust.com/weblog/archives/000511.html">announced another release</a> thanks very much to its creator Cedric Beust.</p>
<p>I am still having some difficulties in responding to change events on the other sliders in the demo, but I think that I just need to decompose the parts into the MVC structure a little more coherently. In particular, when some sliders are moved, it should trigger some calculations and a repaint of the busy label to reflect the changes(not simple properties that can utilize binding directly).  While the original code declares the method inline, I&#8217;ve moved it to the controller class and run into some circular dependency problems between the components referenced therein &#8211; Component A needs Component B but it hasn&#8217;t been instantiated yet in the view, etc. It looks like what is happening is that the change listener is being triggered once when it is assigned to the component, which might be a problem anywhere in Swing/Groovy/Griffon/my implementation. My money is on my own impl, mostly based on the common sense that when you&#8217;re writing code in an unfamiliar area you&#8217;re bound to meet problems that don&#8217;t immediately suggest a solution.</p>
<p>We&#8217;ll just have to keep digging and see. <img src='http://www.kellyrob99.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<div class="ngg-galleryoverview" id="ngg-gallery-2-261">

	<!-- Slideshow link -->
	<div class="slideshowlink">
		<a class="slideshowlink" href="http://www.kellyrob99.com/blog/2009/04/10/more-griffonfest-testing/?show=slide">
			[Show as slideshow]		</a>
	</div>

	<!-- Piclense link -->
	<div class="piclenselink">
		<a class="piclenselink" href="javascript:PicLensLite.start({feedUrl:'http://www.kellyrob99.com/blog/wp-content/plugins/nextgen-gallery/xml/media-rss.php?gid=2&amp;mode=gallery'});">
			[View with PicLens]		</a>
	</div>
	
	<!-- Thumbnails -->
		
	<div id="ngg-image-11" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.kellyrob99.com/blog/wp-content/gallery/griffonswingset/griffonswingset_jxcolorselectionbutton.png" title=" " class="shutterset_set_2" >
								<img title="griffonswingset_jxcolorselectionbutton.png" alt="griffonswingset_jxcolorselectionbutton.png" src="http://www.kellyrob99.com/blog/wp-content/gallery/griffonswingset/thumbs/thumbs_griffonswingset_jxcolorselectionbutton.png" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-12" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.kellyrob99.com/blog/wp-content/gallery/griffonswingset/griffonswingset_testng.png" title=" " class="shutterset_set_2" >
								<img title="griffonswingset_testng.png" alt="griffonswingset_testng.png" src="http://www.kellyrob99.com/blog/wp-content/gallery/griffonswingset/thumbs/thumbs_griffonswingset_testng.png" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 	 	
	<!-- Pagination -->
 	<div class='ngg-clear'></div>
 	
</div>


<!-- AdSense Now! V1.95 -->
<!-- Post[count: 2] -->
<div class="adsense adsense-leadout" style="float:right;margin: 12px;"><script type="text/javascript"><!--
google_ad_client = "pub-6955914197200080";
/* 728x90, created 8/3/09 */
google_ad_slot = "4051815125";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><p>Related posts:<ol>
<li><a href='http://www.kellyrob99.com/blog/2009/04/08/griffon-swingx-fest-testing/' rel='bookmark' title='Griffon SwingX Fest testing'>Griffon SwingX Fest testing</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/04/05/swingx-busy-label-demo-in-griffon/' rel='bookmark' title='SwingX busy label demo in Griffon and Groovy'>SwingX busy label demo in Griffon and Groovy</a></li>
<li><a href='http://www.kellyrob99.com/blog/2010/02/11/a-one-day-griffon-applicationpresentation/' rel='bookmark' title='A One Day Griffon Application/Presentation'>A One Day Griffon Application/Presentation</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.kellyrob99.com/blog/2009/04/10/more-griffonfest-testing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Griffon SwingX Fest testing</title>
		<link>http://www.kellyrob99.com/blog/2009/04/08/griffon-swingx-fest-testing/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=griffon-swingx-fest-testing</link>
		<comments>http://www.kellyrob99.com/blog/2009/04/08/griffon-swingx-fest-testing/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 06:33:38 +0000</pubDate>
		<dc:creator>TheKaptain</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[fest]]></category>
		<category><![CDATA[Graphical user interface]]></category>
		<category><![CDATA[Griffon]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Swing]]></category>
		<category><![CDATA[SwingX]]></category>

		<guid isPermaLink="false">http://www.kellyrob99.com/blog/?p=236</guid>
		<description><![CDATA[This is the third installment of my Griffon SwingSet experiment. If you&#8217;re coming late to the party (and would like to know just what the heck I&#8217;m talking about) you can catch up by reading this and this. So the SwingX demo has 3 sliders that affect integer values on the JXBusyLabel. Using the Groovy [...]
Related posts:<ol>
<li><a href='http://www.kellyrob99.com/blog/2009/04/10/more-griffonfest-testing/' rel='bookmark' title='More Groovy/Griffon/FEST Testing'>More Groovy/Griffon/FEST Testing</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/04/05/swingx-busy-label-demo-in-griffon/' rel='bookmark' title='SwingX busy label demo in Griffon and Groovy'>SwingX busy label demo in Griffon and Groovy</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/04/03/swingset-on-griffon/' rel='bookmark' title='SwingSet on Griffon'>SwingSet on Griffon</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>This is the third installment of my Griffon SwingSet experiment. If you&#8217;re coming late to the party (and would like to know just what the heck I&#8217;m talking about) you can catch up by reading <a href="http://www.kellyrob99.com/blog/2009/04/03/swingset-on-griffon/">this</a> and <a href="http://www.kellyrob99.com/blog/2009/04/05/swingx-busy-la…emo-in-griffon/">this</a>.</p>
<p>So the SwingX demo has 3 sliders that affect integer values on the JXBusyLabel. Using the Groovy &#8216;bind&#8217; syntax, responding to changes in these events is simple to say the least.</p>
<p>And as promised in the last post, I&#8217;ve written some FEST tests to validate that everything is working as expected. Stay tuned to the end of the post to see a video of the running tests <img src='http://www.kellyrob99.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>FEST provides some convenience wrappers for UI elements that allows easy access to common operations. Looking up a JSlider in the UI for instance, returns a JSliderFixture object with a nice little &#8216;slideTo&#8217; method.<br />
First off, here are the UI components under test. Yes, this is the entire code, including all necessary wiring to trigger updates automagically as the sliders are changed.</p>
<pre class="brush: groovy; smart-tabs: true; title: ; notranslate">
speedSlider = slider(
        name: 'speedSlider',
        sliderModel: boundedRangeModel(
                min: 1, max: model.SPEED_MAX - 1, value: model.SPEED_MAX - 1, extent: 0),
        opaque: true)

slider = slider(
        name: 'slider',
        sliderModel: boundedRangeModel(
                min: 1, max: 50, value: 8, extent: 0), opaque: true)

tSlider = slider(
        name: 'tSlider',
        sliderModel: boundedRangeModel(
                min: 1, max: 20, value: 4, extent: 0), opaque: true)

label = jxbusyLabel(name: 'busyLabel',
        preferredSize: new Dimension(model.W / 2 as int, model.H / 2 as int),
        busyPainter: busyPainter(
                highlightColor: bind { model.busyColor }, baseColor: bind {model.baseColor},
                points: bind{slider.value}, trailLength: bind{tSlider.value}),
        opaque: false,
        horizontalAlignment: JLabel.CENTER,
        delay: bind{speedSlider.value})
........
buttons.addLine(button(name: model.START_NAME, action:startAction))
</pre>
<p>And then the tests run against them. Each test moves a slider sequentially from the minimum to the maximum values and checks at each change to ensure that the same change is reflected on the bound JXBusyLabel property. Because the JXBusyLabel does not have a ready corresponding FEST built in fixture class, we just look it up as a Component by inspecting the UI for the appropriate named Component. The Groovy dynamic type system makes accessing its internal properties trivial after that.</p>
<pre class="brush: groovy; smart-tabs: true; title: ; notranslate">
/**
   * Start the animation and then ensure that changing the speed slider changes the delay.
   */
   @Test void testSpeedSlider() {
     def button = window.button(JXBusyLabelDemoModel.START_NAME)
     button.click()
     def JSliderFixture slider = window.slider('speedSlider')
     ComponentFinder finder = BasicComponentFinder.finderWithCurrentAwtHierarchy();
     def busyLabel = finder.findByName(app.appFrames[0], 'busyLabel')
     Assert.assertNotNull(slider)
     Assert.assertNotNull(busyLabel)
     (1..JXBusyLabelDemoModel.SPEED_MAX - 1).each { speed -&gt;
       slider.slideTo(speed)
       Assert.assertEquals(busyLabel.delay, speed)
     }
   }

  /**
   * Start the animation and then ensure that changing the points slider changes the
   * number of points.
   */
   @Test void testPointsSlider() {
     def button = window.button(JXBusyLabelDemoModel.START_NAME)
     button.click()
     def JSliderFixture slider = window.slider('slider')
     ComponentFinder finder = BasicComponentFinder.finderWithCurrentAwtHierarchy();
     def busyLabel = finder.findByName(app.appFrames[0], 'busyLabel')
     Assert.assertNotNull(slider)
     Assert.assertNotNull(busyLabel)
     (1..50).each { points -&gt;
       slider.slideTo(points)
       Assert.assertEquals(busyLabel.busyPainter.points, points)
     }
   }

  /**
   * Start the animation and then ensure that changing the trail slider changes
   * the trailLength.
   */
   @Test void testTrailSlider() {
     def button = window.button(JXBusyLabelDemoModel.START_NAME)
     button.click()
     def JSliderFixture slider = window.slider('tSlider')
     ComponentFinder finder = BasicComponentFinder.finderWithCurrentAwtHierarchy();
     def busyLabel = finder.findByName(app.appFrames[0], 'busyLabel')
     Assert.assertNotNull(slider)
     Assert.assertNotNull(busyLabel)
     (1..20).each { trailLength -&gt;
       slider.slideTo(trailLength)
       Assert.assertEquals(busyLabel.busyPainter.trailLength, trailLength)
     }
   }
</pre>
<p>It&#8217;s particular amusing to note that the test code is more verbose than the Swing component setup. Man, after all of the Swing code I&#8217;ve written, WHY WAS NONE OF IT EVER THIS EASY!<br />
Sorry for the shouting, but it&#8217;s late and updating this code to use binding instead of change listeners AND writing the tests AND writing this blog post took all of about 45 minutes. So you&#8217;ll have to forgive me for getting excited and all.</p>
<p>Here is the promised video <a href="http://www.kellyrob99.com/blog/wp-content/uploads/2009/04/griffonswingxfesttesting.swf">showing the FEST test suite being run.</a>. Give it a second as the first round of tests(not shown in the code above) do a bunch of assertions to make sure that all of the expected Components can be found. Not terribly interesting to watch, but a great win for Java GUI testing!</p>
<p>Related posts:<ol>
<li><a href='http://www.kellyrob99.com/blog/2009/04/10/more-griffonfest-testing/' rel='bookmark' title='More Groovy/Griffon/FEST Testing'>More Groovy/Griffon/FEST Testing</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/04/05/swingx-busy-label-demo-in-griffon/' rel='bookmark' title='SwingX busy label demo in Griffon and Groovy'>SwingX busy label demo in Griffon and Groovy</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/04/03/swingset-on-griffon/' rel='bookmark' title='SwingSet on Griffon'>SwingSet on Griffon</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.kellyrob99.com/blog/2009/04/08/griffon-swingx-fest-testing/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SwingX busy label demo in Griffon and Groovy</title>
		<link>http://www.kellyrob99.com/blog/2009/04/05/swingx-busy-label-demo-in-griffon/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=swingx-busy-label-demo-in-griffon</link>
		<comments>http://www.kellyrob99.com/blog/2009/04/05/swingx-busy-label-demo-in-griffon/#comments</comments>
		<pubDate>Sun, 05 Apr 2009 19:05:18 +0000</pubDate>
		<dc:creator>TheKaptain</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Griffon]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[SwingLabs]]></category>
		<category><![CDATA[SwingX]]></category>

		<guid isPermaLink="false">http://www.kellyrob99.com/blog/?p=169</guid>
		<description><![CDATA[The first demonstration panel in the SwingLabs demo is for the JXBusyLabel, a simple component that does exactly what it says &#8211; inform Users of the application that progress is occurring. The setup is highly configurable, allowing changes to the color, shape and size of the rendered label. The SwingX demonstration makes use of an [...]
Related posts:<ol>
<li><a href='http://www.kellyrob99.com/blog/2009/04/10/more-griffonfest-testing/' rel='bookmark' title='More Groovy/Griffon/FEST Testing'>More Groovy/Griffon/FEST Testing</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/04/08/griffon-swingx-fest-testing/' rel='bookmark' title='Griffon SwingX Fest testing'>Griffon SwingX Fest testing</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/04/03/swingset-on-griffon/' rel='bookmark' title='SwingSet on Griffon'>SwingSet on Griffon</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>The first demonstration panel in the  <a class="zem_slink" title="SwingLabs" rel="homepage" href="https://swinglabs.dev.java.net/">SwingLabs</a> demo is for the JXBusyLabel, a simple component that does exactly what it says &#8211; inform Users of the application that progress is occurring.  The setup is highly configurable, allowing changes to the color, shape and size of the rendered label.</p>
<p>The SwingX demonstration makes use of an inner &#8216;DetailsPane&#8217; class that nicely handles a lot of the gridbag layout details, but I didn&#8217;t really want to spend the extra time Groovifying a perfectly good and already implemented helper class, so I just threw the java code in the <a class="zem_slink" title="Griffon (framework)" rel="homepage" href="http://groovy.codehaus.org/Griffon">Griffon</a> src directory and that was that. Being able to seamlessly mix <a class="zem_slink" title="Java (software platform)" rel="homepage" href="http://java.sun.com">Java</a> and Groovy is a definite plus, let me tell you. Below is an example of adding a new DetailsPane using the builder DSL, utilizing a GridBagConstants variable named &#8216;gbc&#8217; and assigning the foreground color based on a model property.</p>
<pre class="brush: groovy; smart-tabs: true; title: ; notranslate">
genPane = jxpanel(constraints: gbc,
                              new DetailsPane(&quot;General settings:&quot;, model.FOREGROUND))
</pre>
<p>Here is a side-by-side comparison of Java and then the equivalent Groovy code for creating and initializing a new JXBusyLabel. At first they don&#8217;t look a whole lot different, but if you notice, the Groovy version is actually a one-liner, and uses the bind() syntax to set colors based on a model backed property.</p>
<pre class="brush: java; smart-tabs: true; title: ; notranslate">
 label = new JXBusyLabel(new Dimension((int) (W / 2), (int) (H / 2)));
 label.getBusyPainter().setHighlightColor( new Color(44, 61, 146).darker());
 label.getBusyPainter() .setBaseColor(new Color(168, 204, 241).brighter());
 label.setOpaque(false);
 label.setHorizontalAlignment(JLabel.CENTER);
</pre>
<pre class="brush: groovy; smart-tabs: true; title: ; notranslate">
label = jxbusyLabel(
       preferredSize: new Dimension(model.W / 2 as int,model.H / 2 as int),
       busyPainter: busyPainter(highlightColor: bind{ model.busyColor },
       baseColor: bind{model.baseColor}), opaque: false, horizontalAlignment: JLabel.CENTER)
</pre>
<p>SwingX contains a specialized button that wraps a color chooser component, and here we can look at the differences between the Java and Groovy syntax for instantiating one.  The JXColorSelectionButton class isn&#8217;t actually a node made available by the SwingXBuilder, but adding to the builder syntax dynamically is simple to say the least using a call to &#8216;registerBeanFactory&#8217;. Also in the Groovy version, here we&#8217;re not directly updating the color on the label, we&#8217;re updating the model. While the background color change seems to be correctly updated through the bound &#8216;baseColor&#8217; model property, it does not repaint automagically. I&#8217;m sure there&#8217;s a way to do this, it just hasn&#8217;t popped up yet.</p>
<pre class="brush: java; smart-tabs: true; title: ; notranslate">
JXColorSelectionButton baseColBtn = new JXColorSelectionButton();
baseColBtn.setBackground(label.getBusyPainter().getBaseColor());
baseColBtn.addPropertyChangeListener(&quot;background&quot;, new PropertyChangeListener() {
      public void propertyChange(PropertyChangeEvent evt) {
           label.getBusyPainter().setBaseColor((Color) evt.getNewValue());
           label.repaint();
      }});
</pre>
<pre class="brush: groovy; smart-tabs: true; title: ; notranslate">
registerBeanFactory('colorButton', JXColorSelectionButton.class)
baseColBtn = colorButton(background: model.baseColor)
baseColBtn.addPropertyChangeListener(&quot;background&quot;,
      {PropertyChangeEvent evt -&gt;
           model.baseColor = (Color) evt.getNewValue()
           label.repaint()     //need to figure out how to remove this call!!!
      } as PropertyChangeListener)
</pre>
<p>The Java code uses an anonymous inner class to kick off the process.</p>
<pre class="brush: java; smart-tabs: true; title: ; notranslate">
new JButton(new AbstractAction(&quot;Start&quot;) {
      public void actionPerformed(ActionEvent e) {
           label.setBusy(!label.isBusy());
           putValue(Action.NAME, label.isBusy() ? &quot;Stop&quot; : &quot;Start&quot;);
      }
 })
</pre>
<p>No anonymous inner classes in Groovy, and with the Griffon framework we can separate the concerns a bit better anyhow. This code is split up between the view and the controller classes. Note that the controller can reference(and update) the action by acting through its injected view component.</p>
<pre class="brush: groovy; smart-tabs: true; title: ; notranslate">
/* action and button defined in the view */
actions {
      action(id: &quot;startAction&quot;,
      name: model.START_NAME,
      mnemonic: &quot;S&quot;,
      accelerator: shortcut(&quot;S&quot;),
      closure: controller.start)
 }
button(startAction)
...
/* controller action */
def start =  { ActionEvent evt -&gt;
      view.label.setBusy(!view.label.isBusy())
      view.startAction.putValue(Action.NAME, view.label.isBusy() ? &quot;Stop&quot; : &quot;Start&quot;)
 }
</pre>
<p>Finally, here&#8217;s a code sample of how to add a listener to an existing component and bind the action to a method on the controller:</p>
<pre class="brush: groovy; smart-tabs: true; title: ; notranslate">
     xSlider.addChangeListener(controller.&amp;fcl as ChangeListener)
</pre>
<p>In most cases, the sample code here is not trying very hard to shorten the syntax; there&#8217;s a lot of room for improvement and further Groovification. I&#8217;m sure there&#8217;s a better way to add listeners, for instance. Anyhow, aside from a few details, the application is up and running and doing the same thing as the original. Total effort expended: probably about 10 hours, a good portion of it spend  Googling and reading. Next step is to write some tests to get better at that side of the equation.  I&#8217;d be including more links about the excellent SwingX components in this post, but the SwingLabs website has been reporting <a href="http://www.google.ca/search?q=%22Maximum+Connections+Reached%3A+4096+--+Retry+later%22&amp;ie=utf-8&amp;oe=utf-8&amp;aq=t&amp;rls=org.mozilla:en-US:official&amp;client=firefox-a">&#8220;Maximum Connections Reached: 4096 &#8212; Retry later&#8221;</a> all day.  Hope everything gets fixed soon guys!</p>
<p>If you&#8217;re interested in seeing this demo live and  in action, there&#8217;s a link to a short <a class="zem_slink" title="Jing" rel="homepage" href="http://jingproject.com">Jing</a> video below.</p>
<p><a href="http://www.kellyrob99.com/blog/wp-content/uploads/2009/04/griffonswingset3_jxbusylabel.swf">Click here for video of the JXBusyLabel demo running on Griffon.</a></p>
<p>Related posts:<ol>
<li><a href='http://www.kellyrob99.com/blog/2009/04/10/more-griffonfest-testing/' rel='bookmark' title='More Groovy/Griffon/FEST Testing'>More Groovy/Griffon/FEST Testing</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/04/08/griffon-swingx-fest-testing/' rel='bookmark' title='Griffon SwingX Fest testing'>Griffon SwingX Fest testing</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/04/03/swingset-on-griffon/' rel='bookmark' title='SwingSet on Griffon'>SwingSet on Griffon</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.kellyrob99.com/blog/2009/04/05/swingx-busy-label-demo-in-griffon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

