[英]Proper way setting the column width and row height of JTable
I have a custom table with dynamic width and height for each column and row. 我有一个自定义表格,其中每一列和每一行都有动态的宽度和高度。 I also planning to use
JTextField
as TableCellRenderer
. 我还计划将
JTextField
用作TableCellRenderer
。
Should I set the table row height and column width inside the render or inside the custom table?Or there is another place that I can place this? 我应该在渲染器中还是在自定义表格中设置表格的行高和列宽 ?还是可以在另一个地方放置表格?
You can use JTable#setRowHeight(int, int)
to set the height of individual rows and you will need to use the ColumnModel
and obtain a reference to the TableColumn
in order to change it's size. 您可以使用
JTable#setRowHeight(int, int)
设置各个行的高度,并且需要使用ColumnModel
并获取对TableColumn
的引用才能更改其大小。
Remember though, the size of a column may be affected by the autoResizeMode
不过请记住,列的大小可能会受到
autoResizeMode
影响
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.