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;
//  w w w. j av  a2 s.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);

  }
}