• 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() + "
    " + 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;
        }
  • 相关阅读:
    命令实现linux和客户端文件上传下载
    python--linux上如何执行shell命令
    Eureka系列(一)Eureka功能介绍
    Eureka系列(七) 服务下线Server端具体实现
    编译时多态 与 运行时多态
    静态绑定(前期绑定) 与 动态绑定(后期绑定)
    重载 与 重写
    热点检测、方法内联、动态反优化
    数据库日志
    单例模式
  • 原文地址:https://www.cnblogs.com/happyPawpaw/p/3555493.html
Copyright © 2020-2023  润新知