void (final JEditorPane pane) { super.install(pane); // JEditorPane.HONOR_DISPLAY_PROPERTIES must be set after HTMLEditorKit is completely installed pane.addPropertyChangeListener("editorKit", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent e) { // In case JBUI user scale factor changes, the font will be auto-updated by BasicTextUI.installUI() // with a font of the properly scaled size. And is then propagated to CSS, making HTML text scale dynamically. // The default JEditorPane's font is the label font, seems there's no need to reset it here. // If the default font is overridden, more so we should not reset it. // However, if the new font is not UIResource - it won't be auto-scaled. // [tav] dodo: remove the next two lines in case there're no regressions //Font font = getLabelFont(); //pane.setFont(font); // let CSS font properties inherit from the pane's font pane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); pane.removePropertyChangeListener(this); } }); pane.addHyperlinkListener(myHyperlinkListener); java.util.List<LinkController> listeners1 = filterLinkControllerListeners(pane.getMouseListeners()); java.util.List<LinkController> listeners2 = filterLinkControllerListeners(pane.getMouseMotionListeners()); // replace just the original listener if (listeners1.size() == 1 && listeners1.equals(listeners2)) { LinkController oldLinkController = listeners1.get(0); pane.removeMouseListener(oldLinkController); pane.removeMouseMotionListener(oldLinkController); pane.addMouseListener(myLinkController); pane.addMouseMotionListener(myLinkController); } }