import java.awt.Dimension;
import java.awt.Rectangle;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;

public class JListTest {

    public static void main(String[] argv) throws Exception {
        SwingUtilities.invokeAndWait(() -> {
            JFrame f = new JFrame();
            String[] data = {"One", "Two", "Three", "Four", "Five", "Six ", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelv"};
            JList<String> list = new JList<>(data);
            list.setLayoutOrientation(JList.HORIZONTAL_WRAP);

            JScrollPane sp = new JScrollPane(list);
            sp.setPreferredSize(new Dimension(200, 200));
            f.add(sp);
            f.pack();
            f.setVisible(true);

            Rectangle cell = list.getCellBounds(0, 0);
            int unit = list.getScrollableUnitIncrement(
                    cell,
                    SwingConstants.VERTICAL,
                    -1);
            System.out.println("Scrollable unit increment: " + unit);

            if (unit <= 0) {
                throw new RuntimeException("JList scrollable unit increment should be greater than 0.");
            }
            f.dispose();
        });
    }
} 