-
Re: JTable -- resizing column widths
Hello,
I also ran into the same problem, but found a quick work around:
column.setPreferredWidth(width);
column.setMinWidth(width);
column.setMaxWidth(width);
Since this sets the Min, Max, and Preferred to all the same size, Java has
no choice on what size to make things. The one draw back is the user can
no longer resize the columns. Hope that helps!
Stephen
"Jo Desmet" <jo.desmet@advalvas.be> wrote:
>Hoi,
>
>In the sun java tutorials they explain how you can resize the columns to
fit
>all cells in that column. All goes well when this is called only once after
>creation (Model or Data is constant).
>However, I work with a dynamic model (data can be loaded, columns can be
>added, ...), and whatever way I choose, the resizing of the columns have
the
>strange effects:
>
>Way to the strange effects:
>1./ I create the Table with the model, and resize columns: everything ok,
>2./ change the data (using setModel on the table or
>fireTableStructureChanged on the model),
>3./ somehow I resize the columns which as proposed in the sun java
>tutorial. -> first time mostly Ok, second time mostly not.
>4./ resize one of the columns again manually, then repeat 2 and 3 -> first
>time always Ok, second time mostly not
>
>Places to hook-in the functionality of resizing the columns (as I have tried
>with all the same effect):
>1./ override the tableChanged + dynamicly change the Model
>2./ override the tableChanged + use setModel with a newly created model
as
>paramer.
>2./ make a method wich first calls fireTableStructureChanged and then
>resizes the columns. This function should be called manually whenever the
>data changes.
>
>None of them lead me to the expected result.
>Anyone with simular problems?
>
>kr,
>Jo.
>
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks