JScrollPane (JPanel panel) { JPanel wrapper = new JPanel(new BorderLayout()); wrapper.add(panel); wrapper.setBorder(JBUI.Borders.empty(5)); return ScrollPaneFactory.createScrollPane(wrapper, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); }