protected void init() {
	         checkedItems = new boolean[this.getModel().getSize()];
	         class MyCellRenderer extends JCheckBox implements ListCellRenderer {
	
	             public MyCellRenderer() {
	                 setOpaque(true);
	             }
	 
	             public Component getListCellRendererComponent(
	                     JList list,
	                    Object value,
	                    int index,
	                     boolean isSelected,
	                     boolean cellHasFocus) {
	                 //这点代码基本上从DefaultListCellRenderer.java中抄袭的。
	                setComponentOrientation(list.getComponentOrientation());
	                 if (isSelected) {
	                    setBackground(list.getSelectionBackground());
	                     setForeground(list.getSelectionForeground());
	                 } else {
	                     setBackground(list.getBackground());
	                    setForeground(list.getForeground());
	                 }
	 
	                 if (value instanceof Icon) {
	                     setIcon((Icon) value);
	                    setText("");
	                 } else {
	                     setIcon(null);
	                    setText((value == null) ? "" : value.toString());
	                }
	                 setEnabled(list.isEnabled());
	                setFont(list.getFont());
	 
	                //虽然抄袭，可这里别忘了设置check信息。
	                this.setSelected(isChecked(index));
	                 return this;
	             }
	         }
	 
	         this.setCellRenderer(new MyCellRenderer());
	         //定义一个鼠标监听器。如果点击某个item，翻转其check状态。
	         class CheckBoxListener extends MouseAdapter {
	 
	             @Override
	             public void mouseClicked(MouseEvent e) {
	                 int index = locationToIndex(e.getPoint());
	                 invertChecked(index);
	             }
       }
	
	       this.addMouseListener(new CheckBoxListener());
	    }