Tag: Swing

Agents of Swing

The title of this post would make a good name for a band. Anyway, today I’m going to talk about Swing and concurrency and Clojure. The Swing framework is not thread-safe. That may sound strange at first, but there’s actually some sound technical reasoning behind it. Basically, the Swing designers realized that, in order to…

Read the full article

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