Dimension () { if (!prefSizeWasComputed[0] && hintHint.isAwtTooltip()) { JLayeredPane lp = layeredPane; if (lp == null) { JRootPane rootPane = UIUtil.getRootPane(this); if (rootPane != null && rootPane.getSize().width > 0) { lp = rootPane.getLayeredPane(); } } Dimension size; if (lp != null) { AppUIUtil.targetToDevice(this, lp); size = lp.getSize(); prefSizeWasComputed[0] = true; } else { size = ScreenUtil.getScreenRectangle(0, 0).getSize(); } int fitWidth = (int)(size.width * 0.8); Dimension prefSizeOriginal = super.getPreferredSize(); if (prefSizeOriginal.width > fitWidth) { setSize(new Dimension(fitWidth, Integer.MAX_VALUE)); Dimension fixedWidthSize = super.getPreferredSize(); Dimension minSize = super.getMinimumSize(); prefSize = new Dimension(Math.max(fitWidth, minSize.width), fixedWidthSize.height); } else { prefSize = new Dimension(prefSizeOriginal); } } Dimension s = prefSize != null ? new Dimension(prefSize) : super.getPreferredSize(); Border b = getBorder(); if (b != null) { JBInsets.addTo(s, b.getBorderInsets(this)); } return s; }