Hi,
I'm still not getting anywhere trying to center-align labels in a vertical panel. This is what I have tried:
(let [f (frame
:content
(vertical-panel
:items
[(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")
l2 (label :text "Four")
l3 (label :text "Seven")
f (frame
:content
(vertical-panel
:items
[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!