JList.setLayoutOrientation(int layoutOrientation) has the following syntax.
public void setLayoutOrientation(int layoutOrientation)
In the following code shows how to use JList.setLayoutOrientation(int layoutOrientation) method.
import java.awt.BorderLayout; // w w w .ja va2s .c o m import javax.swing.JFrame; import javax.swing.JList; import javax.swing.JScrollPane; public class Main { public static void main(final String args[]) { final String labels[] = { "A", "B", "C", "D", "E" }; JFrame frame = new JFrame("Multi-Columns"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JList columns = new JList(labels); columns.setLayoutOrientation(JList.HORIZONTAL_WRAP); columns.setVisibleRowCount(3); JScrollPane sp = new JScrollPane(columns); frame.add(sp, BorderLayout.CENTER); frame.setSize(300, 200); frame.setVisible(true); } }