The Source for Java Technology Collaboration

Home » java.net Forums » Java Desktop Technologies » SwingLabs

Thread: TablePacker class

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 5 - Last Post: Mar 16, 2009 3:21 AM by: kleopatra Threads: [ Previous | Next ]
uvoigt

Posts: 19
TablePacker class
Posted: Mar 13, 2009 4:42 AM
  Click to reply to this thread Reply

Hi,
I have implemented a class that automatically resizes colums of a table according to the content (or to prototypes or header sizes). It's configurable and is a bit similar to GridBagLayout.
I find it very useful and I want to contribute it to swingx. Maybe it can be used in this context and it can be improved by the wide community.

Where can I upload my class so that you can have a look on it?

I have to add: I have take the original version of this class from http://www.jroller.com/santhosh/date/20061023 and improved it with some configuration stuff.

Ulrich

original source added


Message was edited by: uvoigt

kleopatra

Posts: 1,677
Re: TablePacker class
Posted: Mar 13, 2009 9:39 AM   in response to: uvoigt
  Click to reply to this thread Reply

Hmm ... JXTable already supports enhanced column resize

- there are pack methods to get the smallest size to fit which is actually implemented in the ColumnFactory. The default measures cell content and/or header or takes the column's prototypeValue to measure. Just subclass to implement custom strategies
- there is enhanced support to fit the columns horizontally: see the horizontalScrollEnabled property
- there's a visibleColumnCount property which works similarly as the visibleRowCount property

Don't see a need for a dedicated external packer. But would love to hear what you are missing in the support and merge (preferably as a contribution :-) the missing parts.

Our contribution area is the jdnc-incubator project. There's some paperwork involved to get write access, the details are explained there, just replace Richard's email by Alexander's.

CU
Jeanette

osbald

Posts: 853
Re: TablePacker class
Posted: Mar 13, 2009 10:18 AM   in response to: kleopatra
  Click to reply to this thread Reply

> Don't see a need for a dedicated external packer

Do you see a need to express the packing impl as a pluggable provider so you dont need to override table? Couple of times I've wished to the ability to declare a max size for certain columns (numbers, enums, dates) and have the remainder shared by the content length 'unknown' columns.

kleopatra

Posts: 1,677
Re: TablePacker class
Posted: Mar 13, 2009 12:27 PM   in response to: osbald
  Click to reply to this thread Reply

>
> Do you see a need to express the packing impl as a
> pluggable provider so you dont need to override
> table?

confused about what you mean: override table? For JXTable to way to go is ColumnFactory (which I know you know - so my confusion most probably is due to Friday evening :-) If you indeed mean some kind of pluggable strategy for the factory: yes, certainly I would like that (as I always said, and always pointing to my old age implementation documented at swingempire) but need feedback to what exactly would be needed.

Have a nice weekend
Jeanette

uvoigt

Posts: 19
Re: TablePacker class
Posted: Mar 16, 2009 1:24 AM   in response to: kleopatra
  Click to reply to this thread Reply

I am not very familiar with JXTable. At the moment the major argument for me to use SwingX is the JXTreeTable class.
As long as SwingX does not become an 'official' part of the JDK, I don't like to refactor all my table stuff to SwingX. For me the risk is too high that SwingX fades out and I have to refactor all SwingX stuff back to JDK.

So I was looking for an option to automatically resize my table columns no matter if I use JDK classes or SwingX classes. I didn't find very much and so I started to improve one option, which is not perfect at the moment but it works.
I will try to upload it, so you may have a look on it. Afterwards you can decide yourself if there are some interesting strategies which could also be used for SwingX.

Ulrich

kleopatra

Posts: 1,677
Re: TablePacker class
Posted: Mar 16, 2009 3:21 AM   in response to: uvoigt
  Click to reply to this thread Reply

fair enough. Just suspect that an external packer might clash with xtable's internal handling. Anyway, looking forward to your contribution, always happy to learn the additional trick of the trade :-)

CU
Jeanette




 XML java.net RSS