How to render a JCheckBox on cells of JList?
From: MaoXuePeng (mxp123q_at_126.com)
Date: 10/14/04
- Previous message: Jacques Desmazieres: "Re: Detecting if a table in a database already exists ?"
- Next in thread: David Harper: "Re: How to render a JCheckBox on cells of JList?"
- Reply: David Harper: "Re: How to render a JCheckBox on cells of JList?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 14 Oct 2004 04:13:26 -0400
I do it like this:
public class CheckBoxCellRenderer extends JCheckBox implements
ListCellRenderer {
public CheckBoxCellRenderer() {
super();
}
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
if(isSelected)
{
this.setForeground(java.awt.Color.BLUE);
}
this.setEnabled(isSelected);
this.setText("Hello");
return this;
}
However, there is a problem: I can not select or disselect those check box
rendered in the JList.
What wrong?
Thanks.
MaoXuePeng.
- Previous message: Jacques Desmazieres: "Re: Detecting if a table in a database already exists ?"
- Next in thread: David Harper: "Re: How to render a JCheckBox on cells of JList?"
- Reply: David Harper: "Re: How to render a JCheckBox on cells of JList?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]