博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
prepareEditor
阅读量:5148 次
发布时间:2019-06-13

本文共 3821 字,大约阅读时间需要 12 分钟。

@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
() { @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; }

 

转载于:https://www.cnblogs.com/happyPawpaw/p/3555493.html

你可能感兴趣的文章
虚拟机CentOS设置IP
查看>>
Django之ORM多对多表创建方式,AJAX异步提交,分页器组件等
查看>>
SqlServer查询表名的备注(查询表名描述 MS_Description)
查看>>
去哪网实习总结:递归构建“流程运行顺序”的XML文件(JavaWeb)
查看>>
机器学习笔记十三:Ensemble思想(上)
查看>>
Unity3D中组件事件函数的运行顺序
查看>>
启动tomcat时出现乱码——淇℃伅(转)
查看>>
9.1 正睿提高2
查看>>
HDU.1693.Eat the Trees(插头DP)
查看>>
Java基本语法——(用于日后复习)
查看>>
C# Socket
查看>>
Java的abstract抽象
查看>>
babel编译器相关知识
查看>>
RecyclerView实现点击回复效果
查看>>
windows7安装教程(vmware)
查看>>
Windows Server 2003添加防火墙策略教程
查看>>
济南清北学堂游记 Day 3.
查看>>
System.Threading.Tasks并发和异步代码使用
查看>>
mariadb 重置密码
查看>>
破产姐妹第一季/全集2 Broke Girls迅雷下载
查看>>