AbstractTableModel如何设置内容居中
你是用了AbstractTableModel接口,那你这个代码怎么修改才能使表格内容居中呢??谢谢
你好,可以对具体的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"<[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);
------------------ 原始邮件 ------------------ 发件人: "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. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
好的,谢谢大佬
想请问一下您是怎么登录进去的