again (please help!): center-align vertical labels

Skip to first unread message

Nov 29, 2015, 9:25:12 AM11/29/15
to seesaw-clj

 I'm still not getting anywhere trying to center-align labels in a vertical panel. This is what I have tried:

(let [f (frame
[(label :text "One" :halign :left)
(label :text "Four" :halign :center)
(label :text "Seven" :halign :right)
(-> f pack! show!))

This results in all labels aligned to the left. Using :h-text-position instead or in addition to :halign doesn't change anything.

Trying this gives some effect:

(let [l1 (label :text "One")
(label :text "Four")
(label :text "Seven")
[l1 l2 l3]))]
(.setAlignmentX l1 javax.swing.SwingConstants/LEFT)
(.setAlignmentX l2 javax.swing.SwingConstants/CENTER)
(.setAlignmentX l3 javax.swing.SwingConstants/RIGHT)
(-> f pack! show!)
[(.getAlignmentX l1)
(.getAlignmentX l2)
(.getAlignmentX l3)])

;=> [1.0,0.0,1.0]

Unfortunately l2 is right aligned and the other two left aligned. The return values of -getAlignment suggest something went wrong with setting the alignment as the predefined SwingConstants of LEFT, CENTER and RIGHT are different.
I tried many things, but the documentation in the web i found is too sparse for me. It is quite frustrating not knowing how to get this done after many hours of trial and error. I'm willing to read through any documentation as long as it keeps me from having to reimplement a clojure frontend to swing. Any help is greatly appreciated!

Dave Ray

Nov 29, 2015, 11:03:13 PM11/29/15

Sorry about the slow response. Holidays and stuff. Unfortunately, I don't think you'll get the effect you're going for with a vertical panel. This is because the labels themselves don't expand to fill the horizontal space of the panel so changing the alignment of their text doesn't really have any visible effect. You may have more luck with grid-panel which does expand nested components. Usually the most common approach to any non-trivial layout problem is to use Mig which is supported by seesaw.mig/mig-panel and has fairly good docs at

Hope this helps,

You received this message because you are subscribed to the Google Groups "seesaw-clj" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
For more options, visit

Reply all
Reply to author
0 new messages