@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. 【转载整理】Hibernater的锁机制

    转载原文:http://www.cnblogs.com/otomedaybreak/archive/2012/01/27/2330008.html 概要:数据库事务,事务并发,hibernate悲观锁 ...

  2. android中碰撞屏幕边界反弹问题

    其实碰撞问题只是涉及到一点小算法而已,但在实际应用,尤其游戏中有可能会遇到,下面给出一个小示例,代码如下: MainActivity: package com.lovo; import android ...

  3. js scrollIntoView 滚动到元素可视区域

    老是忘记这个函数名,记录一下啊 // 滚动到可视区域 document.querySelector(".loading").scrollIntoView()

  4. Mac office ppt无法正常输入文字的问题解决方案

     Mac office ppt无法正常输入文字的问题解决方案  Mac下每次启动office ppt后,在输入文字时会出现输入法文本框快速闪退无法正常录入文字的情况,在PowerPoint中会出现这种 ...

  5. eclipse jdk版本设置

    1 Java Build Path(项目的编写环境配置): 在项目上单击右键,properties -> Java Build Path -> Libraries,选择JRE System ...

  6. 从ext4将mysql数据目录移动至lustre出现(InnoDB: Unable to lock ./ibdata1, error: 38.)

    因为数据目录过大,因此我把目录从本地移到了共享存储中.在修改了/etc/my.cnf和/etc/init.d/mysqld之后发现数据库可以运行,但启动速度很慢 原因是原文件系统是ext4,而目标文件 ...

  7. Hadoop 读取文件API报错

    Exception in thread "main" org.apache.hadoop.hdfs.BlockMissingException: Could not obtain ...

  8. 参数化查询 '(@ActualShipTime datetime' 需要参数 @AuthorizationNumber,但未提供该参数。

    转自 http://www.cnblogs.com/cxd4321/archive/2012/08/09/2629716.html 在平时的C#项目开发中,当调用某个存储过程或函数的时候,我们可能经常 ...

  9. 【Unity】2.6 游戏视图(Game)

    分类:Unity.C#.VS2015 创建日期:2016-03-29 一.简介 游戏视图 (Game View) 从游戏的相机 ((Camera(s)) 中呈现,代表所发布游戏的最终版.你将需要一台或 ...

  10. Codeforces Round #Pi (Div. 2)(A,B,C,D)

    A题: 题目地址:Lineland Mail #include <stdio.h> #include <math.h> #include <string.h> #i ...