コード例 #1
0
 public Component getListCellRendererComponent(
     JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
   JCheckBox checkbox = (JCheckBox) value;
   if (!UIUtil.isUnderNimbusLookAndFeel()) {
     checkbox.setBackground(getBackground(isSelected, checkbox));
     checkbox.setForeground(getForeground(isSelected, checkbox));
   }
   checkbox.setEnabled(isEnabled());
   checkbox.setFont(getFont(checkbox));
   checkbox.setFocusPainted(false);
   checkbox.setBorderPainted(true);
   checkbox.setBorder(isSelected ? mySelectedBorder : myBorder);
   adjustRendering(checkbox, isSelected, cellHasFocus);
   return checkbox;
 }
コード例 #2
0
 public Component getListCellRendererComponent(
     JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
   if (containerBox == null) {
     containerBox = Box.createHorizontalBox();
     checkBox = new JCheckBox();
     checkBox.setEnabled(isEnabled());
     checkBox.setFont(getFont());
     checkBox.setFocusPainted(false);
     checkBox.setBorderPainted(true);
     checkBox.setBorder(
         isSelected ? UIManager.getBorder("List.focusCellHighlightBorder") : noFocusBorder);
     containerBox.add(checkBox);
   }
   checkBox.setBackground(isSelected ? getSelectionBackground() : getBackground());
   checkBox.setForeground(isSelected ? getSelectionForeground() : getForeground());
   if (value != null) {
     ListItem item = (ListItem) value;
     checkBox.setText(item.dataItem.toString());
     checkBox.setSelected(item.selected);
   }
   return containerBox;
 }