void () { try { if (myText != null && myText.startsWith("<html>")) { super.setText(myText); // SwingUtilities2.clipString does not support HTML return; } FontMetrics fm = getFontMetrics(getFont()); int textWidth = UIUtilities.stringWidth(this, fm, myText); int prefWidth = myIconWithInsetsWidth + textWidth; int maxWidth = getMaximumSize().width; if (prefWidth > maxWidth) { int offset = maxWidth - myIconWithInsetsWidth; String s = UIUtilities.clipString(this, fm, myText, offset); super.setText(s); return; } super.setText(myText); } finally { //noinspection ConstantConditions if (myContent != null && !(myContent instanceof SingleContentLayout.SubContent) && !Disposer.isDisposed(myContent) && !textUpdateScheduled) { textUpdateScheduled = true; EdtScheduledExecutorService.getInstance().schedule(() -> { textUpdateScheduled = false; Container parent = getParent(); if (parent != null) { parent.revalidate(); parent.repaint(); } }, 50, TimeUnit.MILLISECONDS); } } }