JList: setLayoutOrientation(int ori)
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JScrollPane;
public class MainClass {
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);
}
}
Related examples in the same category