• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dynamicaly optimising column width

 
Jon Entwistle
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

Jon
[ July 06, 2004: Message edited by: Jon Entwistle ]
 
Jon Entwistle
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Forget the question - I have taken out this extra code and allowed the table set its own widths for simplicities sake

Jon
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic