StudentManagement icon indicating copy to clipboard operation
StudentManagement copied to clipboard

AbstractTableModel如何设置内容居中

Open LJG-V opened this issue 6 years ago • 4 comments

你是用了AbstractTableModel接口,那你这个代码怎么修改才能使表格内容居中呢??谢谢

LJG-V avatar Feb 07 '20 04:02 LJG-V

你好,可以对具体的JTable表格对象设置单元格渲染器TableCellRenderer,单元格渲染器的方法可以设置其单元格内容居中:setHorizontalAlignment(SwingConstants.CENTER)或者setHorizontalAlignment(JLabel.CENTER),效果是一样的,参数均为常量0。具体代码为: DefaultTableCellRenderer tableCellRenderer = new DefaultTableCellRenderer(); tableCellRenderer.setHorizontalAlignment(JLabel.CENTER); jTable.setDefaultRenderer(Object.class,tableCellRenderer);

------------------ 原始邮件 ------------------ 发件人: "LJG-V"<[email protected]>; 发送时间: 2020年2月7日(星期五) 中午12:09 收件人: "commonyzb/StudentManagement"<[email protected]>; 抄送: "Subscribed"<[email protected]>; 主题: [commonyzb/StudentManagement] AbstractTableModel如何设置内容居中 (#3)

你是用了AbstractTableModel接口,那你这个代码怎么修改才能使表格内容居中呢??谢谢

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

commonyzb avatar Feb 07 '20 05:02 commonyzb

好的,谢谢,刚改好

------------------ 原始邮件 ------------------ 发件人: "commonyzb"<[email protected]>; 发送时间: 2020年2月7日(星期五) 中午1:14 收件人: "commonyzb/StudentManagement"<[email protected]>; 抄送: "1308715622"<[email protected]>;"Author"<[email protected]>; 主题: Re: [commonyzb/StudentManagement] AbstractTableModel如何设置内容居中 (#3)

你好,可以对具体的JTable表格对象设置单元格渲染器TableCellRenderer,单元格渲染器的方法可以设置其单元格内容居中:setHorizontalAlignment(SwingConstants.CENTER)或者setHorizontalAlignment(JLabel.CENTER),效果是一样的,参数均为常量0。具体代码为: DefaultTableCellRenderer tableCellRenderer = new DefaultTableCellRenderer(); tableCellRenderer.setHorizontalAlignment(JLabel.CENTER); jTable.setDefaultRenderer(Object.class,tableCellRenderer);

------------------&nbsp;原始邮件&nbsp;------------------ 发件人:&nbsp;"LJG-V"<[email protected]&gt;; 发送时间:&nbsp;2020年2月7日(星期五) 中午12:09 收件人:&nbsp;"commonyzb/StudentManagement"<[email protected]&gt;; 抄送:&nbsp;"Subscribed"<[email protected]&gt;; 主题:&nbsp;[commonyzb/StudentManagement] AbstractTableModel如何设置内容居中 (#3)

你是用了AbstractTableModel接口,那你这个代码怎么修改才能使表格内容居中呢??谢谢

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

LJG-V avatar Feb 07 '20 05:02 LJG-V

好的,谢谢大佬

hhucYang avatar Apr 04 '20 12:04 hhucYang

想请问一下您是怎么登录进去的

muhenan avatar Jun 27 '20 11:06 muhenan