/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
super(comboBox);
}
}
boolean fSelected;
boolean fChecked;
boolean fInList;
boolean fEditable;
boolean fDrawCheckedItem = true;
// Provides space for a checkbox, and is translucent
super();
}
// Don't include checkIcon space, because this is also used for button size calculations
// - the popup-size calc will get checkIcon space from getInsets
// From BasicComboBoxRenderer - trick to avoid zero-height items
setText(" ");
size = super.getPreferredSize();
setText("");
} else {
size = super.getPreferredSize();
}
return size;
}
// Don't paint the border here, it gets painted by the UI
}
}
// Really means is the one with the mouse over it
public Component getListCellRendererComponent(final JList list, final Object value, int index, final boolean isSelected, final boolean cellHasFocus) {
if (index < 0) {
}
// changed this to not ask for selected index but directly compare the current item and selected item
// different from basic because basic has no concept of checked, just has the last one selected,
// and the user changes selection. We have selection and a check mark.
// we used to call fComboBox.getSelectedIndex which ends up being a very bad call for large checkboxes
// it does a linear compare of every object in the checkbox until it finds the selected one, so if
// we have a 5000 element list we will 5000 * (selected index) .equals() of objects.
// See Radar #3141307
// Fix for Radar # 3204287 where we ask for an item at a negative index!
if (index >= 0) {
} else {
fChecked = false;
}
if (isSelected) {
if (fEditable) {
} else {
}
} else {
if (fEditable) {
} else {
}
}
} else {
}
return this;
}
return insets;
}
this.fDrawCheckedItem = drawCheckedItem;
}
// Paint this component, and a checkbox if it's the selected item and not in the button
if (fInList) {
} else {
g.setColor(getBackground());
}
final int y = getHeight() - 4;
g.setColor(getForeground());
}
}
super.paintComponent(g);
}
}