Category: Groovy
-
Making a Groovy class a range
In a recent post, I used the Date class in a range. This always jumps out at Java developers, who aren’t used to seeing it. It’s really cool you can do that in Groovy. That example illustrates both the concept of a range as a collection of values, and that Groovy can add methods to…
-
Links from my GroovyMag article
I’m really happy to have an article in the current issue of GroovyMag, but after it appeared I realized something. When I submitted the article I added several links in the text, thinking that they would still be active in the resulting PDF. That, as they say, turned out not to be the case. I…
-
Groovy Groundhogs
So the groundhog saw his shadow today, implying six more weeks of Winter. Let’s settle this nonsense once and for all. The output is In other words, there are six weeks and six days between Groundhog Day and the first day of Spring. So we’re already going to have an early Spring. 🙂
-
Making Swing Groovy, Part III: EDT
In this entry in my “Making Swing Groovy” series, I want to talk about threading issues. Specifically, how to work with the Event Dispatch Thread. As a step along the way, let me first respond to a comment made about my first post in this series. Kirill Grouchnikov collects interesting Swing-related links every week. He…
-
Making Swing Groovy, Part II: Binding
In my previous post in this series, I presented a trivial Echo GUI written in Groovy. By using SwingBuilder and closures, the code for the GUI was dramatically simplified compared to the Java version. But Groovy can go beyond that. In this post, I’ll talk about the bind method and the @Bindable annotation, which help…
-
Making Swing Groovy, Part I
I’ve been spending a lot of time lately trying to understand how much Groovy improves Swing user interfaces. Like so many Java developers, I rarely write client-side programs. Almost all of my time and effort with Java over at least the last five years has been on the server side, mostly with frameworks like Struts,…
-
Getting a list of Grails plugins programmatically
In September, I’m very happy to be giving a couple of presentations at the No Fluff, Just Stuff conference in the Boston area. One of my presentations is a review of the various available Grails plugins. To prepare for that, I thought I’d create a Grails application that acted as a survey, so people could…
-
assert != assertEquals (duh)
It’s probably not great for my reputation to show how I made a very silly error, but since I did it so consistently I thought showing it might help somebody avoid it. My Groovy course materials consist of far more scripts than classes. That’s probably not surprising, given that teaching Groovy involves writing lots and…
-
Using Groovy to determine Unicode characters
(Technically speaking, this post doesn’t require Groovy. You could do the same thing in Java. Still, as usual, Groovy is easier.) I’m teaching a Groovy course this week and having a great time doing it. One of the exercises I put together is to create a concordance, which is a map relating individual words to…
-
Turning Java enums into Groovy ranges
It turns out that it’s easy to turn a Java enum into a type that can be used in a Groovy range. Consider a simple enum representing the seasons: public enum Season { WINTER, SPRING, SUMMER FALL } Since enums implement the Comparable interface, they have a compareTo() method. Despite that, however, you can’t use…