Skip to content

Commit

Permalink
Added grid-layout
Browse files Browse the repository at this point in the history
  • Loading branch information
odyssomay committed Jun 14, 2011
1 parent e4e06e9 commit 2286b4f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/Hafni/swing/layout.clj
Expand Up @@ -2,7 +2,7 @@
(:use (Hafni utils arrow event)
(Hafni.swing component))
(:import (javax.swing BoxLayout JPanel)
(java.awt BorderLayout CardLayout FlowLayout)))
(java.awt BorderLayout CardLayout FlowLayout GridLayout)))

(defn border-layout
"Create a BorderLayout
Expand Down Expand Up @@ -85,3 +85,19 @@ Fields:
"right" FlowLayout/RIGHT
(throw (Exception. ""))))}]
(init-comp cont arrs nil opts)))

(defn grid-layout
"Create a GridLayout
Fields:
:content - content of layout | [Component]
:hgap - Horizontal gap between components | Int
:vgap - Vertical gap between components | Int"
[rows cols & options]
(let [opts (parse-options options)
layout (GridLayout. rows cols)
cont (JPanel. layout)
arrs {:content (fn [coll]
(dorun (map #(.add cont (component %)) coll)))
:hgap #(.setHgap layout %)
:vgap #(.setVgap layout %)}]
(init-comp cont arrs nil opts)))

0 comments on commit 2286b4f

Please sign in to comment.