• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Visuals...determining the right table column size, gui size ?

 
Karl Fu
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do you determine the right column size for each row?
i tried to use the formula "fields.length * CONSTANT" for each column's width..but not every column's heading will have enough space to be displayed. If i increase the constant to give space to show all columns, then my gui will almost covered up my entired screen...and the carrier column will have too many space wasted.
Any suggestion ?
I also tried to format the column header into 2 rows if they are composite of 2 or more words....but the display remains unchanged. How do i accomplish that ?
Thanks in advance
Karl
 
Narayan Veeramani
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For having multiple lines on the column header in the JTable,
you need to use the cell renderer object associated with the
table header of the JTable. You can get the renderer
as follows and then perform the column header rendering.
TableCellRenderer headerRenderer = table.getTableHeader().
getDefaultRenderer();
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic