Here you can find the source of downListSelectedIndex(JList sourceList)
public static void downListSelectedIndex(JList sourceList)
//package com.java2s; import javax.swing.DefaultListModel; import javax.swing.JList; public class Main { public static void downListSelectedIndex(JList sourceList) { int selectedIndex = sourceList.getSelectedIndex(); DefaultListModel listModel = (DefaultListModel) sourceList .getModel();//from w w w. j av a2 s .co m if (selectedIndex < listModel.size() - 1) { Object selectedValue = listModel.get(selectedIndex); Object newSelectedValue = listModel.get(selectedIndex + 1); listModel.set(selectedIndex, newSelectedValue); listModel.set(selectedIndex + 1, selectedValue); sourceList.setSelectedIndex(selectedIndex + 1); sourceList.ensureIndexIsVisible(sourceList.getSelectedIndex()); } } }