void (@NotNull JComponent component) { JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(component); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); scrollPane.setHorizontalScrollBar(null); scrollPane.setBorder(new NavBarBorder()); JPanel navBarPanelWrapper = new JPanel(new BorderLayout()) { @Override public void doLayout() { // align vertically Rectangle r = getBounds(); Insets insets = getInsets(); int x = insets.left; Dimension preferredSize = scrollPane.getPreferredSize(); scrollPane.setBounds(x, (r.height - preferredSize.height) / 2, r.width - insets.left - insets.right, preferredSize.height); } }; navBarPanelWrapper.add(scrollPane, BorderLayout.CENTER); myNavBarPanel.add(navBarPanelWrapper, BorderLayout.CENTER); }