• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

table row height

 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a JTable with a comboBox as a cell editor.

This works fine but looks a little bad.

The comboBox needs to be editable. When the user clicks on a cloumn in the table whose editor is the combo box, it appears to be not tall enough.

Here are some code snippets to show you what I mean:
[code]
// create the table
final JTable table = new JTable(new MyTableModel( ));

// create the combo box
JComboBox acctsComboBox = new JComboBox(theAccounts);
acctsComboBox.setEditable( true );

// set the editor
TableColumn descColumn = table.getColumnModel().getColumn(2);
descColumn.setCellEditor(new DefaultCellEditor( acctsComboBox ));

// adjust the width of the column
int preferredWidth = getWidestEntry( acctsComboBox,
table.getFontMetrics(table.getFont()), table.getGraphics());

if (preferredWidth >= 0)
descColumn.setPreferredWidth( preferredWidth );
[\code]
 
Bring me the box labeled "thinking cap" ... and then read this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic