public void install(JEditorPane c) { MouseListener[] oldMouseListeners = c.getMouseListeners(); MouseMotionListener[] oldMouseMotionListeners = c.getMouseMotionListeners(); super.install(c); // the following code removes link handler added by original // HTMLEditorKit for (MouseListener l : c.getMouseListeners()) { c.removeMouseListener(l); } for (MouseListener l : oldMouseListeners) { c.addMouseListener(l); } for (MouseMotionListener l : c.getMouseMotionListeners()) { c.removeMouseMotionListener(l); } for (MouseMotionListener l : oldMouseMotionListeners) { c.addMouseMotionListener(l); } // add out link handler instead of removed one c.addMouseListener(handler); c.addMouseMotionListener(handler); }
private void initDebugTextPane() { HTMLEditorKit htmlEditorKit = new HTMLEditorKit(); HTMLDocument htmlDocument = new HTMLDocument(); debugTextPane.setEditable(false); debugTextPane.setBackground(Color.WHITE); debugTextPane.setEditorKit(htmlEditorKit); htmlEditorKit.install(debugTextPane); debugTextPane.setDocument(htmlDocument); }