> But it seems that the cell height is a little to small for a
> jtextfield with border.
JTable has a default row height of 16 pixels.
The brain dead part is that you have to adjust this by hand
using setRowHeight. If you use a different font or put a
custom component in the table the table does not get the
preferred size from the contents.
See
http://www.chka.de/swing/table/cell-sizes.html
> So i made a little function which makes all
> cells in a jtable the same height as a standard jtextfield:
[quoted text clipped - 9 lines]
> This seems like a nice working hack, but i'm wondering if this is the
> right thing to do. Any ideas about this?
Seems resonable. It works.
You might want to put a sanity check in case some other JVMs/JREs dont
work the same. (Possible that empty textField might have default 0s).
eg (untested code)
public FieldTable()
{
super()
int rowHeight = (int)new JTextField().getPreferredSize().getHeight();
if (rowHeight >= 1) this.setRowHeight(rowHeight);
}
Ding - 19 Mar 2004 16:15 GMT
>> But it seems that the cell height is a little to small for a
>> jtextfield with border.
[quoted text clipped - 5 lines]
>See
>http://www.chka.de/swing/table/cell-sizes.html
Thats a handy link, thanks.
>> So i made a little function which makes all
>> cells in a jtable the same height as a standard jtextfield:
[quoted text clipped - 20 lines]
> if (rowHeight >= 1) this.setRowHeight(rowHeight);
>}
Thanks, it's good to do it at the save way :)
Ding - 19 Mar 2004 16:19 GMT
>>> But it seems that the cell height is a little to small for a
>>> jtextfield with border.
[quoted text clipped - 7 lines]
>
>Thats a handy link, thanks.
After browsing a little more at the given link i've come to the
conclusion that it really is a nice site. I'm wondering why google
didnt gave me that site. It's now on my desktop :-)