File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

table row height

 
jefff willis
Ranch Hand
Posts: 113
  • 0
  • Mark post as helpful
  • send pies
  • 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]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic