prepareEditor
@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的更多相关文章
随机推荐
- Android编译系统环境初始化过程分析
Android源代码在编译之前,要先对编译环境进行初始化,其中最主要就是指定编译的类型和目标设备的型号.Android的编译类型主要有eng.userdebug和user三种,而支持的目标设备型号则是 ...
- 硬盘 SMART 检测参数详解[转]
一.SMART概述 硬盘的故障一般分为两种:可预测的(predictable)和不可预测的(unpredictable).后者偶而会发生,也没有办法去预防它,例如芯片突然失效,机械撞击等.但像电机轴承 ...
- unity, shader, Tags的位置
Tags写在Pass里,是不对的,比如: 结果一看shader的Inspector面板,Render queue的值居然不是3001,而是2000: 改为: 再看shader的inspector面板, ...
- 给Elasticsearch 5.2.2 设置用户权限 how to setting security for elasticsearch on windows
1. download the plugin of elasticsearch: 下载 readonlyrest-1.14.0_es5.2.2.zip 2. install readonlyrest ...
- Vue2 原理解析
现代主流框架均使用一种数据=>视图的方式,隐藏了繁琐的dom操作,采用了声明式编程(Declarative Programming)替代了过去的类jquery的命令式编程(Imperative ...
- Java 清除指定目录文件夹下文件
public static void clearFiles(String filePath){ File scFileDir = new File(filePath); File TrxFiles[] ...
- pandas数组获取最大值索引的方法-argmax和idxmax
pandas Series 的 argmax 方法和 idxmax 方法用于获取 Series 的最大值的索引值: 举个栗子: 有一个pandas Series,它的索引是国家名,数据是就业率,要找出 ...
- pandas数组(pandas Series)-(1)
导入pandas import pandas as pd countries = ['Albania', 'Algeria', 'Andorra', 'Angola', 'Antigua and Ba ...
- TF-IDF理解及其Java实现
TF-IDF 前言 前段时间,又具体看了自己以前整理的TF-IDF,这里把它发布在博客上,知识就是需要不断的重复的,否则就感觉生疏了. TF-IDF理解 TF-IDF(term frequency–i ...
- bash(3):遍历文件
#!/bin/bash function getdir(){ ` do dir_or_file=$"/"$element if [ -d $dir_or_file ] then g ...