Change the layout orientation so that its items are displayed top-to-bottom and left-to-right. : JList Renderer « Swing « Java Tutorial






import javax.swing.JList;
import javax.swing.JScrollPane;

public class Main {
  public static void main(String[] argv) throws Exception {
    String[] items = { "A", "B", "C", "D" };
    JList list = new JList(items);
    JScrollPane scrollingList = new JScrollPane(list);

    // Change orientation to top-to-bottom, left-to-right layout
    list.setLayoutOrientation(JList.VERTICAL_WRAP);
  }
}








14.41.JList Renderer
14.41.1.Rendering JList Elements
14.41.2.Install List cell rendererInstall List cell renderer
14.41.3.Add your own ListCellRendererAdd your own ListCellRenderer
14.41.4.Creating a Complex ListCellRenderer: font, icon and colorCreating a Complex ListCellRenderer: font, icon and color
14.41.5.The items can be arbitrary objects. The toString() method of the objects is displayed in the list component.
14.41.6.Setting the Dimensions of an Item in a JList Component
14.41.7.Set the item dimensions using a sample value
14.41.8.Change the layout orientation so that its items are displayed top-to-bottom and left-to-right.