JComponent (JComponent component, boolean inheritBackground) { BorderLayoutPanel panel; if (inheritBackground) { panel = new BorderLayoutPanel() { @Override public Color getBackground() { return component.getBackground(); } }; } else { panel = JBUI.Panels.simplePanel(); panel.setOpaque(false); } panel.addToCenter(component); panel.addToRight(myExpandButton); return panel; }