Forums Register Login
Dynamicaly optimising column width
Hi everyone,

I have tried to implement the GUI using standard useability guidelines, going for a simple, unclutered and (hopefuly) intuitive design.

Having said that, I am not sure if I have gone over the top for column resizing. I was not happy at the idea of hard coding width values into the view, and not too keen on just relying on the cell header names as a guide to determine initial cell size either.

My view frame allows 'pluggable' JPanels for the view to facilitate change, and I have implemented a nested JTable JPanel for the assignment. I have included an inner class in this panel which queries the table model for the row with the greatest preferred width in each column based (using the actual rendering component), then determined wether this would be wider than the actual header cell component for this column. These 'ideal' widths for each column are then used to determine the 'best fit' for each column based on the actual viewport size. This inner class also listens for resize events to ensure that this proportion is maintained on a resize.

While it works fine, I am not sure if this is going over the top - I don't think it is overly complex (100 lines or so plus a single method interface to be implemented by the table model) but I certainly don't want to loose marks over it. Is it best to rip it out, hard code the values and be done with it (hey, I learnt a lot in the process )?

Any thoughts appreciated

[ July 06, 2004: Message edited by: Jon Entwistle ]
Forget the question - I have taken out this extra code and allowed the table set its own widths for simplicities sake

Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards

All times above are in ranch (not your local) time.
The current ranch time is
Dec 11, 2017 08:08:50.