I have built a bunch of J4ME layout components. They aren't exactly
quality to be integrated into the main library, though they have
helped me a lot. If you want I can send them to you to have a look,
and maybe load them on a contrib/ directory or something?
Also, there are 2 types of layouts. Those that take a single
component, and those that take multiple components.
They're all related to putting components side by side or doing some
type of magic on them like alignment. They themselves extend the
Component class and can simply be added as components themselves. The
J4ME library already handles components along the vertical axis, so
these components don't handle that. In fact, they can't. The only time
I felt I needed this was to add space between 2, in which case I
simply used the Whitespace component, which fills a fixed amount of
pixels vertically.
Further, I have some examples showing most of them. I think I covered
all of them, though the examples were made months ago, so they might
be missed. Further they are pretty self explanatory. They can also be
used together, like to center a component you can use the Vertical and
Horizontal alignment together. Though there is a quirk in this I
haven't solved, where you have to use them in the correct order when
doing this or it makes the target component smaller than it's
preferred size.
Here they are:
ContainerPanel - Abstract class for laying out one or more components
along the width of a panel. Some of the following extend on this class
LayoutPanel - Abstract class for laying out a single component. Some
of the following extend on this class
EqualWidthContainer - Lays out components with equal widths. Used in
the GridRow/GridContainer
FixedHeightLayout - Makes the items along the width of fixed heights.
GeneralContainer - Implementation class to list components side by
side, giving them their preferred widths.
GridLayoutContainer - Not a layout per se, but rather a class that
generates components+layouts. You add the components to this class and
then "attach" it to a dialog. It will then generate the layouts
necessary to layout in a grid. Supports giving columns dynamic widths,
fixed widths, same for rows.
GridRow - Layout component to the formats components into "columns".
Used in the attach process of the GridLayoutContainer
HorizontalAlignLayout - Takes a single component and aligns it in the
middle of the available space horizontally
VerticalAlignLayout - Takes a single component and aligns it in the
middle of the available space vertically
The handle selections well. Note that the rest of the API needs some
modifications to support them. So if you want them I'll send them to
you with a complete package. I'm a bit tight on time for the next 2/3
weeks, but I'll have a look at the changes needed and perhaps see how
I can minimize them or document them or create a patch - IF you choose
to take them.
Quintin Beukes