aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes table row height Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "table row height" Watch "table row height" New topic
Author

table row height

jefff willis
Ranch Hand

Joined: Sep 29, 2004
Posts: 113
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
 
subject: table row height
 
Similar Threads
JTable +JComboBox
A JTable question
Jtable combo box issue
JTable and Combobox editor
Obvious JCombobox in a JTable?