コード例 #1
0
  public Component getListCellRendererComponent(
      JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    if (value != null) {
      panel.setTodoItem((TodoItem) value);
    }
    if (isSelected) {
      adjustColors(list.getSelectionBackground(), list.getSelectionForeground());
    } else {
      adjustColors(list.getBackground(), list.getForeground());

      if ((index % 2) == 0) {
        panel.setBackground(STRIPE_COLOR);
        adjustColors(STRIPE_COLOR, list.getForeground());
      }
    }

    return panel;
  }
コード例 #2
0
 public TodoListCellRenderer() {
   panel = new ListItemPanel();
   panel.setOpaque(true);
 }