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 / March 2005

Tip: Looking for answers? Try searching our database.

Presetting column width in JTable without disabling autoresize?

Thread view: 
Anton Golovko - 22 Mar 2005 13:45 GMT
Hi!

Is there any way to preset column width in pixels wihtout disabling
auto resize in JTable?

Here is my situation:
1. The first column of the table needs to be preset to 30 pixels.
2. I don't want horizontal a scrollbar to appear.
3. I cannot use TableColumn.setMaxWidth, because I want user to be
able to resize column sizes.

TableColumn.setPreferredWidth doesn't work here, the table increases
the width  of my column anyway.

Please help!

Regards,
Anton
John McGrath - 22 Mar 2005 17:20 GMT
> Is there any way to preset column width in pixels wihtout disabling
> auto resize in JTable?
[quoted text clipped - 7 lines]
> TableColumn.setPreferredWidth doesn't work here, the table increases
> the width  of my column anyway.

Initially, it does set the column width to its preferred width.  But given
how you have set up the table, it must fill the width of the scroll pane,
so the extra space has to go somewhere, and it distributes the extra space
among the columns.  If you set the preferred widths of the columns so that
it adds up to the table width, the columns will remain sized at their
preferred widths.

Signature

Regards,

John McGrath



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.