void (Container parent) { Insets insets = parent.getInsets(); Dimension size = parent.getSize(); int innerHeight = size.height - insets.top - insets.bottom; Dimension menuButtonSize = myMenuButton.getPreferredSize(); int x = size.width - menuButtonSize.width - insets.right; int y = (innerHeight - menuButtonSize.height) / 2; myMenuButton.setBounds(x, y + insets.top, menuButtonSize.width, menuButtonSize.height); Dimension myHintButtonSize = myHintButton.getPreferredSize(); if (myHintButton.isVisible() && !myProcessIcon.isVisible()) { x -= myHintButtonSize.width; y = (innerHeight - myHintButtonSize.height) / 2; myHintButton.setBounds(x, y + insets.top, myHintButtonSize.width, myHintButtonSize.height); } else if (!myHintButton.isVisible() && myProcessIcon.isVisible()) { Dimension myProcessIconSize = myProcessIcon.getPreferredSize(); x -= myProcessIconSize.width; y = (innerHeight - myProcessIconSize.height) / 2; myProcessIcon.setBounds(x, y + insets.top, myProcessIconSize.width, myProcessIconSize.height); } else if (!myHintButton.isVisible() && !myProcessIcon.isVisible()) { x -= myHintButtonSize.width; } else { throw new IllegalStateException("Can't show both process icon and hint button"); } Dimension adSize = myAdvertiser.getAdComponent().getPreferredSize(); y = (innerHeight - adSize.height) / 2; myAdvertiser.getAdComponent().setBounds(insets.left, y + insets.top, x - insets.left, adSize.height); }