Made a custom ListCellRenderer:
import java.awt.Component;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
/**
*
* @author Spencer
*/
public class TaskRenderer implements ListCellRenderer {
private Task task;
private JPanel panel = new JPanel();
private JCheckBox checkbox = new JCheckBox();
private JLabel label = new JLabel();
public TaskRenderer() {
panel.add(checkbox);
panel.add(label);
}
public Component getListCellRendererComponent(
JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus) {
task = (Task) value;
label.setText(task.getName());
return panel;
}
}
Have a JList with each cell in it rendered using the above class, but the checkboxes in the panels for each cell cannot be clicked. Thought it had to do with it not getting focus. Any ideas?
Thanks, Spencer