[Snow-devel] Having troubles with size property

Alessio Stalla alessiostalla at gmail.com
Thu Jun 16 20:51:35 UTC 2011


On Thu, Jun 16, 2011 at 10:07 PM, Matus Kmit <simply.nitaai at gmail.com> wrote:
> Hi Alessio
>
> i am having troubles using the size property. it just doesn't work as
> i want. so far it seems to be working only with frame widget.
>
> What i basically want is a scrollable non-editable text area of a specific size.
>
> Here is my test code:
>
> (frame (:size #C(300 300))
>  (panel (:layout "wrap")
>   (label :text "1")
>   (label :text "2")
>   (label :text "3" :layout "wrap")
>   (label :text "2" :layout "span 2 2")
>   (label :text "2" :layout "wrap")
>   (label :text "2"))
>  (scroll (:size #C(100 100))
>   (label :text
> "looooooooooooooooooooooooooooooooooooooooooooooooooooooooooong"))
>  (show self))
>
> i tried various options, but did not succeed. Size in frame works, but
> not in scroll.
>
> Your help is appreciated,
> Matus

Size is a naughty beast in Swing. There are multiple variants of it:
actual, minimum, maximum, and preferred size, and how they work, if
they work at all, is determined by the layout manager. For MigLayout,
the default used by Snow, the easiest option is to forget about the
size properties altogether and use layout constraints, in your case:

(scroll (:layout "w 100, h 100") ...)

or width/height instead of w/h if you prefer longer names.

hth,
Alessio




More information about the snow-devel mailing list