Java JList.isSelectedIndex(int index)

Syntax

JList.isSelectedIndex(int index) has the following syntax.

public boolean isSelectedIndex(int index)

Example

In the following code shows how to use JList.isSelectedIndex(int index) method.


/* w w  w  .j  a  v a 2s .c  o m*/
import javax.swing.JList;

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

    int index = 2;
    boolean isSel = list.isSelectedIndex(index);
  }
}