Example usage for javax.swing JList indexToLocation

List of usage examples for javax.swing JList indexToLocation

Introduction

In this page you can find the example usage for javax.swing JList indexToLocation.

Prototype

public Point indexToLocation(int index) 

Source Link

Document

Returns the origin of the specified item in the list's coordinate system.

Usage

From source file:JListLocationToIndexSample.java

public static void main(String args[]) {
    String labels[] = { "A", "B", "C", "D", "E", "F", "G", "H" };
    JFrame frame = new JFrame("Selecting JList");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JList jlist = new JList(labels);
    JScrollPane scrollPane1 = new JScrollPane(jlist);
    frame.add(scrollPane1, BorderLayout.CENTER);

    System.out.println(jlist.indexToLocation(5));
    frame.setSize(350, 200);//from   w w w .  j  av  a 2 s  . co m
    frame.setVisible(true);
}