0

How can I get a JList to show in a JPenel. For example I'd like to have the following groups of items displayed in a JPanel, with each group showing on it's own column, with a new group being dropped into a new line, like how Google lists search results.

For example:

import java.util.ArrayList;
import java.util.List;
import javax.swing.JPanel;


public class ReaderImpl {
    JPanel paneTo = new JPanel();

    List<String> text() {
        List<String> lovely = new ArrayList<String>(4);
            lovely.add("Tall, Short, Average");         // line 1
            lovely.add("mangoes, apples, Bananas");     // line 2
            lovely.add("12, 33");  
        return lovely;
    }

    // How do I add the lovely ArrayList to paneTo
}
Oliver Muchai
  • 279
  • 1
  • 8
  • 18

1 Answers1

1

A JList renderer can draw a checkbox, but JList does not support a cell editor. Instead, consider a one-column JTable.

Check out this link here.

Hope that helps.

Community
  • 1
  • 1
JNL
  • 4,683
  • 18
  • 29
  • @olicvermuchai Not a problem. I would appreciate if the answer helped you, can you upvote or accept the answer and close the question. Thanks – JNL Jul 31 '13 at 15:24
  • 1
    I will a bit later. can't upvote you right now: just joined StackOverflow and my points aren't high enough. – Oliver Muchai Jul 31 '13 at 15:32