Example usage for javax.swing DefaultListModel toString

List of usage examples for javax.swing DefaultListModel toString

Introduction

In this page you can find the example usage for javax.swing DefaultListModel toString.

Prototype

public String toString() 

Source Link

Document

Returns a string that displays and identifies this object's properties.

Usage

From source file:Main.java

public static void main(final String args[]) {
    String labels[] = { "A", "B", "C", "D", "E" };
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    DefaultListModel model = new DefaultListModel();
    model.ensureCapacity(1000);//w  w  w .ja v a 2 s.  c  om
    for (int j = 0; j < 5; j++) {
        model.addElement(labels[j]);
    }
    System.out.println(model.toString());

    JList jlist2 = new JList(model);
    jlist2.setVisibleRowCount(4);
    jlist2.setFixedCellHeight(12);
    jlist2.setFixedCellWidth(200);
    JScrollPane scrollPane2 = new JScrollPane(jlist2);
    frame.add(scrollPane2, BorderLayout.CENTER);

    frame.setSize(300, 350);
    frame.setVisible(true);
}