[英]how to make a Jbutton as rectangle
I have a sortableTableModel
. 我有一个
sortableTableModel
。 On click of column headers I sort the content. 单击列标题后,将对内容进行排序。 For sorting, column headers are treated as
jbutton
. 为了进行排序,列标题被视为
jbutton
。
Now my jbutton
are created with rounded corners so in my table column headers have rounded corner . 现在,我的
jbutton
被创建为带有圆角,因此在我的表列标题中具有圆角 。
I want those as plane rectangles . 我想要那些作为平面矩形 。
how can I achieve that? 我该如何实现?
You can do something like this - 你可以做这样的事情-
TableColumn col = table.getColumnModel().getColumn(vColIndex);
col.setHeaderRenderer(new CustomTableHeaderRenderer());
And then create your own TableCellRenderer that extends whatever JComponent you wish. 然后创建自己的TableCellRenderer,以扩展所需的JComponent。
您将需要设置边框/对表标题中使用的按钮进行一些自定义绘制修改。
if is your Java version 1.6 ++, than why not using default TableHeader
that's came with JTable
(by defalut returns JLabel
) and with defalut RowSorter
http://download.oracle.com/javase/tutorial/uiswing/components/table.html#sorting , 如果是你的Java版本1.6 ++,比为什么不使用默认
TableHeader
多数民众赞成附带JTable
(由defalut返回JLabel
),并与defalut RowSorter
http://download.oracle.com/javase/tutorial/uiswing/components/table.html #sorting ,
but another situations could be if is implemented in your sortableTableModel
custom RowFilter
但是如果在您的
sortableTableModel
自定义RowFilter
实现了另一种情况
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.