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 / December 2003

Tip: Looking for answers? Try searching our database.

Controlling the size of a text field...

Thread view: 
alan - 29 Dec 2003 17:50 GMT
I'm using a 3x2 grid layout in a JPanel.  The left column are labels
and the right columns are JTextFields.  These text fields contain
values that are only a few chars long (numbers generally).  My problem
is that the text fields are filling up the whole block on the grid but
I'd like them to be of a fixed size, so they won't change if the
window is resized.

Is there a simple way of doing this?  Or, failing that, a complicated
way...

thanks for your help.

alan
Lee Weiner - 29 Dec 2003 18:40 GMT
>I'm using a 3x2 grid layout in a JPanel.  The left column are labels
>and the right columns are JTextFields.  These text fields contain
[quoted text clipped - 5 lines]
>Is there a simple way of doing this?  Or, failing that, a complicated
>way...

The simple way is to put JPanels (with default FlowLayout) into the cells in
the right column and add the JTextFields to the panels.

Lee Weiner
lee AT leeweiner DOT org
Karsten Lentzsch - 29 Dec 2003 19:28 GMT
> I'm using a 3x2 grid layout in a JPanel.  The left column are labels
> and the right columns are JTextFields.  These text fields contain
[quoted text clipped - 4 lines]
>
> Is there a simple way of doing this?  [...]

If you want the text fields use individual width
then set the column property or use the constructor
that accepts the columns and let the layout manager
honor the text fields preferred size.

In the Forms layout system you could write:

FormLayout layout = new FormLayout(
   "pref, 4dlu, left:pref, 3dlu, left:pref");

DefaultFormBuilder builder = new DefaultFormBuilder(layout);
builder.setDefaultDialogBorder();
builder.append("Label1", field11, field12);
builder.append("Label2", field21, field22);
return builder.getPanel();

The Forms open source project is hosted at
JavaDesktop.org, where you can download the
library, sources, a tutorial and tutorial sources,
see http://forms.dev.java.net/

You can find screenshots and more demos at
http://www.jgoodies.com/freeware/forms/

Best regards,
Karsten


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.