Mega Code Archive

 
Categories / Java / Swing JFC
 

Make the number of visible rows dependent on the height of the list, the visibleRowCount property must be set to 0

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);     // Make the number of rows dynamic     list.setVisibleRowCount(0);   } }