@Override
public Component prepareEditor(TableCellEditor editor, int row, int column) {
final Component comp = super.prepareEditor(editor, row, column);
if (column == this.convertColumnIndexToView(this.treeRenderCol) && comp != null) {
final int r = this.convertRowIndexToModel(row), col = column; final Rectangle rect = this.getCellRect(r, column, false);
JPanel panel = new JPanel() {
private static final long serialVersionUID = -4503378912490172443L; @Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
CTreeTable.this.tree.highlightBorder = null;
CTreeTable.this.tree.rowToPaint = r;
CTreeTable.this.tree.colToPaint = col;
CTreeTable.this.tree.setBounds(rect.x, 0, rect.width, 0);
Graphics g2 = null;
try {
g2 = g.create();
CTreeTable.this.tree.paint(g2);
}
finally {
if (g2 != null) {
g2.dispose();
}
}
} @SuppressWarnings("boxing")
protected boolean processCompKeyBinding(final JComponent jcomp, final KeyStroke ks, final KeyEvent e,
final int condition, final boolean pressed) {
boolean retr = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
@Override
public Boolean run() {
boolean b = false;
try {
Method m =
JComponent.class.getDeclaredMethod("processKeyBinding", KeyStroke.class,
KeyEvent.class, int.class, boolean.class);
m.setAccessible(true);
b = (Boolean) m.invoke(jcomp, ks, e, condition, pressed);
}
catch (Exception e1) {
// e1.printStackTrace();
XBRLLogger.info(e1.getMessage() + "\n" + e1.getStackTrace().toString(), true);
}
return b;
}
});
return retr;
} @Override
protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
if (comp instanceof JComponent) {
boolean b =
this.processCompKeyBinding((JComponent) comp, ks, e, JComponent.WHEN_FOCUSED, pressed);
if (CTreeTable.this.getSurrendersFocusOnKeystroke()) {
comp.requestFocus();
}
return b;
}
return super.processKeyBinding(ks, e, condition, pressed);
} };
panel.setLayout(null);
panel.setBounds(rect);
int x = this.tree.getRowBounds(r).x;
TreeCellRenderer tcr = this.tree.getCellRenderer();
if (tcr != null && tcr instanceof DefaultTreeCellRenderer) {
DefaultTreeCellRenderer dtcr = (DefaultTreeCellRenderer) tcr;
x += dtcr.getIconTextGap() + dtcr.getIcon().getIconWidth();
}
comp.setBounds(x, 0, rect.width - x, rect.height);
panel.add(comp);
return panel;
}
return comp;
}

prepareEditor的更多相关文章

随机推荐

  1. C# 类中索引器的使用

    索引器(Indexer)是C#引入的一个新型的类成员,它使得类中的对象可以像数组那样方便.直观的被引用.索引器非常类似于属性,但索引器可以有参数列表,且只能作用在实例对象上,而不能在类上直接作用.定义 ...

  2. 【转载并整理】javaweb单点登录

    很好的一篇,讲述原理的文章: http://www.importnew.com/22863.html https://www.cnblogs.com/Leo_wl/p/6111623.html 京东s ...

  3. 简单示例:Spring4 整合 单个Redis服务

    1. 引入spring-data-redis.jar API:https://docs.spring.io/spring-data/redis/docs/current/api/org/springf ...

  4. 温故而知新 前端日志上传新姿势 navigator.sendBeacon(信标)

    原文地址:https://mp.weixin.qq.com/s/-moAfEZicrFmun4qfWLdOQ 简单示例js: var data = JSON.stringify({ name: 'Be ...

  5. cent os 6.5+ambari+HDP集群安装

    1. 搭建一个测试集群,集群有4台机器,配置集群中每一台机器的/etc/hosts文件: [root@nn .ssh]# cat /etc/hosts 127.0.0.1 localhost loca ...

  6. jquery 取子节点及当前节点属性值

    分享下jquery取子节点及当前节点属性值的方法. <li class="menulink"><a href="#" rel="ex ...

  7. cmd命令操作Oracle数据库

    //注意cmd命令执行的密码字符不能过于复杂 不能带有特殊符号 以免执行不通过 譬如有!@#¥%……&*之类的  所以在Oracle数据库设置密码是不要太复杂 /String Database ...

  8. Vue.js使用-组件示例(实现数据的CRUD)

    1.业务场景 用户(姓名,年龄,性别)的增删改查 2.数据格式 定义字段,name:字段名称,iskey:是否主键(添加,修改数据标志),dataSource:可选列表(下拉框选项) columns: ...

  9. 【MySQL】MySQL在CentOS的搭建

    安装mysql 查询yum服务器上可用的关于mysql的安装包: [root@localhost ~]# yum list | grep mysql mysql-libs.x86_64 5.1.71- ...

  10. ubuntu创建用户命令

    可以用adduser和useradd来添加用户,用userdel来删除用户. 最简单的命令:sudo adduser test会自动同名组,创建/home/test/,从etc/skel/复制文件,并 ...