3 The file is used to create cell renderer for CheckBoxList Item
5 Copyright (c) 2006, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 package org
.tianocore
.frameworkwizard
.common
.ui
.iCheckBoxList
;
19 import javax
.swing
.border
.*;
21 class ICheckBoxListCellRenderer
extends JCheckBox
implements ListCellRenderer
{
23 /// Define class Serial Version UID
25 private static final long serialVersionUID
= -1718072217181674870L;
27 protected static Border noFocusBorder
= new EmptyBorder(1, 1, 1, 1);
30 This is the default Constructor
33 public ICheckBoxListCellRenderer() {
36 setBorder(noFocusBorder
);
40 * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
41 * Override to get attribute of the ICheckListCellRenderer
44 public Component
getListCellRendererComponent(JList list
, Object value
, int index
, boolean isSelected
,
45 boolean cellHasFocus
) {
46 ICheckBoxListItem item
= (ICheckBoxListItem
) value
;
48 setComponentOrientation(list
.getComponentOrientation());
50 if (item
.isChecked()) {
51 setBackground(list
.getSelectionBackground());
52 setForeground(list
.getSelectionForeground());
55 setBackground(Color
.LIGHT_GRAY
);
56 setForeground(list
.getForeground());
58 setBackground(list
.getBackground());
59 setForeground(list
.getForeground());
63 if (value
instanceof ICheckBoxListItem
) {
64 setText(item
.getText());
65 setSelected(item
.isChecked());
68 setText((value
== null) ?
"" : value
.toString());
71 setEnabled(list
.isEnabled());
72 setFont(list
.getFont());