Java tutorial
import java.awt.BorderLayout; import javax.swing.JFrame; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; public class Main { public static void main(String[] args) { JFrame frame = new JFrame(); JPanel panel = new JPanel(); JScrollPane listScrollPane = new JScrollPane(); String[] stringArray = { "Testing", "This", "Stuff" }; JList<String> rowList = new JList<>(stringArray); rowList.setVisibleRowCount(2); listScrollPane.setViewportView(rowList); panel.setLayout(new BorderLayout()); panel.add(listScrollPane); frame.add(panel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); } }