void (Container parent) { lm.layoutContainer(parent); JComboBox cb = (JComboBox)parent; Dimension aps = arrowButton.getPreferredSize(); Dimension pps = myPanel.getPreferredSize(); int availableWidth = cb.getWidth() - aps.width; if (comboBox.getComponentOrientation().isLeftToRight()) { myPanel.setBounds( Math.max(availableWidth - pps.width, 0), (cb.getHeight() - pps.height) / 2, Math.min(pps.width, availableWidth), pps.height ); } else { myPanel.setBounds( arrowButton.getWidth(), (cb.getHeight() - pps.height) / 2, Math.min(pps.width, availableWidth), pps.height ); } }