This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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 combo box issue
A JTable question
JTable and Combobox editor
Obvious JCombobox in a JTable?
JTable +JComboBox