Question: How to display a simple ListView in Java? Could you please give me a simple sample code on how to create ListView?

Answer: 
Have a look at [Java swing tutorial](http://docs.oracle.com/javase/tutorial/ui/overview/demo.html) and [ListView](http://docs.oracle.com/javase/1.5.0/docs/api/javax/swing/text/html/ListView.html) API reference - Its an implementation of `<html>` list - `<ol><li>`. 

Sample :

```
public class Sample extends JFrame   {
    public Sample(){
        JEditorPane pane = new JEditorPane();
        pane.setContentType("text/html");
        pane.setText("<ol id='foo'><li>One</li><li>Two</li></ol>"); 
        HTMLDocument doc = (HTMLDocument) pane.getDocument();
        add(pane);

        //Get the ref of foo element
        Element ele=doc.getElement("foo");
        ListView view=new ListView(ele);
        System.out.println(ele.getElementCount());
        try{
             doc.insertBeforeEnd(ele.getElement(0), "<ul><li>Test");          
        }catch(Exception ex){}
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(300,300);
        setVisible(true);
    }
}

```
According tho the JavaDocs it is used when rendering HTML, so using it is is just a matter of loading some HTML that uses an HTML list (`<ul>` or `<ol>`).

![Show HTML List](https://i.stack.imgur.com/WQu0K.png)

```
import java.awt.*;
import javax.swing.*;

class ShowHtmlList {
    public static void main(String[] args) {
        final StringBuilder sb = new StringBuilder();
        // invoke HTML renderring in HTML aware components
        sb.append("<html>");
        // start (the body &) an ordered list
        sb.append("<body><ol>");
        Font[] fonts = GraphicsEnvironment.
            getLocalGraphicsEnvironment().getAllFonts();
        for (Font font : fonts) {
            String name = font.getName();
            // will be rendered using a *** ListView ***
            sb.append("<li style='font-family: " + 
                name + "; font-size: 20px;'>");
            sb.append(name);
        }
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                JScrollPane sp = new JScrollPane(
                    new JLabel(sb.toString()));
                Dimension d = sp.getPreferredSize();
                sp.setPreferredSize(new Dimension(d.width, 150));
                JOptionPane.showMessageDialog(null, sp);
            }
        });
    }
}

```

---

OTOH it might be the data is better presented in a `JList` as suggested in a number of other replies.