开发者

How to left or right justify a column header in a JTable

I searched and couldn't find an answer for this. By default column headers in a JTab开发者_JAVA百科le are centered. How do I make certain column headers left or right justified instead?

TIA


TableCellRenderer renderer = new DefaultTableCellRenderer();
renderer.setHorizontalAlignment(SwingConstants.RIGHT);
table.getColumn(id).setHeaderRenderer(renderer);

Or, if you don't have the column names available:

table.getColumnModel().getColumn(index).setHeaderRenderer(renderer);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜