jgoodies DefaultFormBuilder adding a custom component

T

timasmith

Hi,

I have been successfully using jgoodies DefaultFormBuilder to
dynamically build my forms with TextFields, FormattedFields, DateFields
etc.

Now I want to build a custom control which consists of a JTextField and
an elipse button
[ ] [...]
So the user can initiate a search from the button.

So I create the 2 components, placed them on a JPanel and fixed the
size 130,23 of the JPanel.

However when I create the component it is resized to a height of 1 for
some unknown reason.

DefaultFormBuilder builder = LayoutUtility.getDefaultBuilder(2);
builder.append(label, getCustomControl());

CustomControl extends JPanel, and adds controls and sets size (and min
size) in the constructor.

Event calling on the panel to set size after it was added to the form
has no effect.

Anyone familiar with this perchance?

thanks

Tim
 
K

Karsten Lentzsch

I have been successfully using jgoodies DefaultFormBuilder to
dynamically build my forms with TextFields, FormattedFields, DateFields
etc.

Now I want to build a custom control which consists of a JTextField and
an elipse button
[ ] [...]
So the user can initiate a search from the button.

So I create the 2 components, placed them on a JPanel and fixed the
size 130,23 of the JPanel.

I recommend to not set a fixed size;
and if you set a fixed size, do not specificy
in in pixel. If the hardware screen resolution
changes, the pixel size of (130, 23) may be
perceived as larger or smaller. Today's popular LCDs
have a hardware resolution between 80dpi and 144dpi.
So the perceived width could shrink to the half.
However when I create the component it is resized to a height of 1 for
some unknown reason.

DefaultFormBuilder builder = LayoutUtility.getDefaultBuilder(2);
builder.append(label, getCustomControl());

The DefaultFormBuilder is intended for (larger)
default forms. A sub-panel with two components
with a fixed size is not a default form. And so,
I'd not use the DefaultFormBuilder. In such a
simple case, you may want to use the simpler
PanelBuilder (often a good choice) or use no
builder at all.

I suggest that you browse the Forms "Tips & Tricks"
that you can find from the Forms' README.html.
Anyone familiar with this perchance?

You may consider posting a runnable example
in the Forms user mailing list (see the README.html).
In that list, a lot of people can assist you.

-Karsten Lentzsch
 
T

timasmith

Thanks Karsten for your time.

Turns out I was foolish and was using panel.setSize(...) instead of
panel.setPreferredSize(...) - only the latter works
So placing 2 controls on a panel to make a custom control works just
fine with the DefaultFormBuilder - I will read up on the tips and
tricks for preferred methods.

I must say I *love* your jgoodies toolset.

thanks

Tim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top