Tag: Clojure

Heating Up Clojure & Swing

Most Swing examples don’t translate well into Clojure because they are so thoroughly embedded in the object-oriented paradigm. A typical Swing example has a main class that extends a container class and implements some *Listener interface.  Clojure beginners who try to port these examples may think they need to mimic that same structure. In fact,…

Read the full article

Taming the GridBagLayout

GUI layout is hard. You’d be crazy to do it without a GUI designer like Netbeans. Well, I’m pretty crazy. So I’m going to do some GUI layout in Clojure. And I’m going to use the most intimidating of Java’s GUI layout classes, the GridBagLayout. Conceptually, GridBagLayout is pretty straightforward. It places components on a…

Read the full article

doto Swing with Clojure

One of the great things about Clojure is how it can make Java programming easier and less verbose. Take Swing.  It takes a ton of code to render even a simple GUI.  Most tutorials don’t even tackle it without an IDE like NetBeans. But we’ve got something Java lacks: macros! In this post, I’ll build…

Read the full article

Swing Into Actions with Clojure

My previous post left you with a Clojure/Swing GUI consisting of one window and one button.  Boring!  Let’s make it do something. To catch up, start a Clojure REPL and type: (import ‘(javax.swing JFrame JPanel JButton)) (def button (JButton. “Click Me!”)) (def panel (doto (JPanel.) (.add button))) (def frame (doto (JFrame. “Hello Frame”) (.setSize 200…

Read the full article

First Steps With Clojure & Swing

Swing is the GUI standard for Java.  Clojure is the awesomeness standard for Java.  Let’s make an awesome GUI. Make a Window Interactive development is fun.  Fire up a Clojure REPL, and type this: (import ‘javax.swing.JFrame) (def frame (JFrame. “Hello Frame”)) (.setSize frame 200 200) (.setVisible frame true) Hey Presto, there’s a window!  (It might…

Read the full article

It’s About the Platform

I’ve said It’s About the Libraries, and indeed, one of the major selling points of Clojure is that it can call Java libraries directly. But there’s more to it than that.  Libraries are just one benefit to building Clojure on top of Java, or, more accurately, on top of Java the platform. Look around you,…

Read the full article

Cutting-Edge Clojure Development with Maven

I promised, in my previous post, that I would show you how to use the latest-and-greatest versions of Clojure and clojure-contrib in your Maven projects. Here’s that post. Formos Software maintains a Maven server with nightly builds of Clojure and contrib at http://tapestry.formos.com/maven-snapshot-repository/ Here’s a complete pom.xml file with dependencies on both Clojure and clojure-contrib:…

Read the full article