Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / February 2006

Tip: Looking for answers? Try searching our database.

jgoodies DefaultFormBuilder adding a custom component

Thread view: 
timasmith@hotmail.com - 26 Feb 2006 20:40 GMT
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
Karsten Lentzsch - 27 Feb 2006 17:21 GMT
> I have been successfully using jgoodies DefaultFormBuilder to
> dynamically build my forms with TextFields, FormattedFields, DateFields
[quoted text clipped - 7 lines]
> 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
timasmith@hotmail.com - 28 Feb 2006 00:44 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.