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
}
4

1 回答 1

1

渲染器JList可以绘制复选框,但JList 支持单元格编辑器。相反,考虑一列JTable.

在此处查看此链接。

希望有帮助。

于 2013-07-31T15:05:24.947 回答