void (@NotNull Window popupWindow) { Rectangle screenRectangle = ScreenUtil.getScreenRectangle(myToolbar); String text = myTextViewer.getText(); FontMetrics fontMetrics = myTextViewer.getFontMetrics(EditorUtil.getEditorFont()); int width = fontMetrics.stringWidth(text) + TOOLBAR_MARGIN; int toolbarWidth = myToolbar.getPreferredSize().width + TOOLBAR_MARGIN; int newWidth = Math.max(toolbarWidth, width); newWidth = Math.min(newWidth, getMaxPopupWidth(screenRectangle)); newWidth = Math.max(newWidth, getMinPopupWidth(screenRectangle)); updatePopupBounds(popupWindow, newWidth, popupWindow.getHeight()); }