Java Swing Tutorial - Java JList.setPrototypeCellValue(E prototypeCellValue)








Syntax

JList.setPrototypeCellValue(E prototypeCellValue) has the following syntax.

public void setPrototypeCellValue(E prototypeCellValue)

Example

In the following code shows how to use JList.setPrototypeCellValue(E prototypeCellValue) method.

import javax.swing.JList;
/*www.ja v a 2s  .  co  m*/
public class Main {
  public static void main(String[] argv) throws Exception {
    String[] items = { "A", "B", "C", "D" };
    JList list = new JList(items);

    String protoCellValue = "My Sample Item Value";
    list.setPrototypeCellValue(protoCellValue);

  }
}