Rectangle (@NotNull JComponent container) { Rectangle rec = container.getVisibleRect(); Dimension iconSize = getPreferredSize(); return new Rectangle(rec.x + rec.width - iconSize.width, rec.y, iconSize.width, iconSize.height); }