src/share/classes/javax/swing/plaf/basic/BasicComboPopup.java
Print this page
@@ -69,23 +69,23 @@
public Object getElementAt(int index) { return null; }
public void addListDataListener(ListDataListener l) {}
public void removeListDataListener(ListDataListener l) {}
};
- static final ListModel EmptyListModel = new EmptyListModelClass();
+ static final ListModel<Object> EmptyListModel = new EmptyListModelClass();
private static Border LIST_BORDER = new LineBorder(Color.BLACK, 1);
- protected JComboBox comboBox;
+ protected JComboBox<Object> comboBox;
/**
* This protected field is implementation specific. Do not access directly
* or override. Use the accessor methods instead.
*
* @see #getList
* @see #createList
*/
- protected JList list;
+ protected JList<Object> list;
/**
* This protected field is implementation specific. Do not access directly
* or override. Use the create method instead
*
* @see #createScroller
@@ -227,11 +227,11 @@
}
/**
* Implementation of ComboPopup.getList().
*/
- public JList getList() {
+ public JList<Object> getList() {
return list;
}
/**
* Implementation of ComboPopup.getMouseListener().
@@ -301,11 +301,11 @@
* Removes the listeners from the combo box model
*
* @param model The combo box model to install listeners
* @see #installComboBoxModelListeners
*/
- protected void uninstallComboBoxModelListeners( ComboBoxModel model ) {
+ protected void uninstallComboBoxModelListeners( ComboBoxModel<?> model ) {
if (model != null && listDataListener != null) {
model.removeListDataListener(listDataListener);
}
}
@@ -317,11 +317,11 @@
//===================================================================
// begin Initialization routines
//
- public BasicComboPopup( JComboBox combo ) {
+ public BasicComboPopup( JComboBox<Object> combo ) {
super();
setName("ComboPopup.popup");
comboBox = combo;
setLightWeightPopupEnabled( comboBox.isLightWeightPopupEnabled() );
@@ -479,12 +479,12 @@
* the items in the combo box model. This method is called when the UI class
* is created.
*
* @return a <code>JList</code> used to display the combo box items
*/
- protected JList createList() {
- return new JList( comboBox.getModel() ) {
+ protected JList<Object> createList() {
+ return new JList<Object>( comboBox.getModel() ) {
public void processMouseEvent(MouseEvent e) {
if (BasicGraphicsUtils.isMenuShortcutKeyDown(e)) {
// Fix for 4234053. Filter out the Control Key from the list.
// ie., don't allow CTRL key deselection.
Toolkit toolkit = Toolkit.getDefaultToolkit();
@@ -608,11 +608,11 @@
* <code>uninstallComboBoxModelListeners</code>.
*
* @param model The combo box model to install listeners
* @see #uninstallComboBoxModelListeners
*/
- protected void installComboBoxModelListeners( ComboBoxModel model ) {
+ protected void installComboBoxModelListeners( ComboBoxModel<?> model ) {
if (model != null && (listDataListener = createListDataListener()) != null) {
model.addListDataListener(listDataListener);
}
}
@@ -926,16 +926,19 @@
//
// PropertyChangeListener
//
public void propertyChange(PropertyChangeEvent e) {
- JComboBox comboBox = (JComboBox)e.getSource();
+ @SuppressWarnings("unchecked")
+ JComboBox<Object> comboBox = (JComboBox)e.getSource();
String propertyName = e.getPropertyName();
if ( propertyName == "model" ) {
- ComboBoxModel oldModel = (ComboBoxModel)e.getOldValue();
- ComboBoxModel newModel = (ComboBoxModel)e.getNewValue();
+ @SuppressWarnings("unchecked")
+ ComboBoxModel<Object> oldModel = (ComboBoxModel)e.getOldValue();
+ @SuppressWarnings("unchecked")
+ ComboBoxModel<Object> newModel = (ComboBoxModel)e.getNewValue();
uninstallComboBoxModelListeners(oldModel);
installComboBoxModelListeners(newModel);
list.setModel(newModel);
@@ -953,11 +956,11 @@
// Pass along the new component orientation
// to the list and the scroller
ComponentOrientation o =(ComponentOrientation)e.getNewValue();
- JList list = getList();
+ JList<?> list = getList();
if (list!=null && list.getComponentOrientation()!=o) {
list.setComponentOrientation(o);
}
if (scroller!=null && scroller.getComponentOrientation()!=o) {
@@ -976,11 +979,12 @@
//
// ItemListener
//
public void itemStateChanged( ItemEvent e ) {
if (e.getStateChange() == ItemEvent.SELECTED) {
- JComboBox comboBox = (JComboBox)e.getSource();
+ @SuppressWarnings("unchecked")
+ JComboBox<Object> comboBox = (JComboBox)e.getSource();
setListSelection(comboBox.getSelectedIndex());
}
}
}
@@ -1170,11 +1174,11 @@
*/
protected int getPopupHeightForRowCount(int maxRowCount) {
// Set the cached value of the minimum row count
int minRowCount = Math.min( maxRowCount, comboBox.getItemCount() );
int height = 0;
- ListCellRenderer renderer = list.getCellRenderer();
+ ListCellRenderer<Object> renderer = list.getCellRenderer();
Object value = null;
for ( int i = 0; i < minRowCount; ++i ) {
value = list.getModel().getElementAt( i );
Component c = renderer.getListCellRendererComponent( list, value, i, false, false );