javax.swing.JList 设置分割线

public class TestJList extends JFrame {
    public TestJList() {
        JList list = new JList(new String[] { "cc", "zz", "pp" });
        this.add(list);
        list.setCellRenderer(new DefaultListCellRenderer() {
            public void paintComponent(Graphics g) {
                super.paintComponent(g);
                g.setColor(Color.red);
                g.drawLine(0, getHeight() - 1, getWidth(), getHeight() - 1);
            }
        });
        this.setTitle("Test JList");
        this.pack();
        this.setVisible(true);
    }
    public static void main(String[] args) {
        TestJList t = new TestJList();
    }
}

posted @ 2015-06-18 14:52  ℉utur_īng  阅读(1355)  评论(0编辑  收藏  举报