src/share/classes/javax/swing/plaf/basic/BasicComboPopup.java
Print this page
*** 69,91 ****
public Object getElementAt(int index) { return null; }
public void addListDataListener(ListDataListener l) {}
public void removeListDataListener(ListDataListener l) {}
};
! static final ListModel EmptyListModel = new EmptyListModelClass();
private static Border LIST_BORDER = new LineBorder(Color.BLACK, 1);
! protected JComboBox 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;
/**
* This protected field is implementation specific. Do not access directly
* or override. Use the create method instead
*
* @see #createScroller
--- 69,91 ----
public Object getElementAt(int index) { return null; }
public void addListDataListener(ListDataListener l) {}
public void removeListDataListener(ListDataListener l) {}
};
! static final ListModel<Object> EmptyListModel = new EmptyListModelClass();
private static Border LIST_BORDER = new LineBorder(Color.BLACK, 1);
! 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<Object> list;
/**
* This protected field is implementation specific. Do not access directly
* or override. Use the create method instead
*
* @see #createScroller
*** 227,237 ****
}
/**
* Implementation of ComboPopup.getList().
*/
! public JList getList() {
return list;
}
/**
* Implementation of ComboPopup.getMouseListener().
--- 227,237 ----
}
/**
* Implementation of ComboPopup.getList().
*/
! public JList<Object> getList() {
return list;
}
/**
* Implementation of ComboPopup.getMouseListener().
*** 301,311 ****
* Removes the listeners from the combo box model
*
* @param model The combo box model to install listeners
* @see #installComboBoxModelListeners
*/
! protected void uninstallComboBoxModelListeners( ComboBoxModel model ) {
if (model != null && listDataListener != null) {
model.removeListDataListener(listDataListener);
}
}
--- 301,311 ----
* Removes the listeners from the combo box model
*
* @param model The combo box model to install listeners
* @see #installComboBoxModelListeners
*/
! protected void uninstallComboBoxModelListeners( ComboBoxModel<?> model ) {
if (model != null && listDataListener != null) {
model.removeListDataListener(listDataListener);
}
}
*** 317,327 ****
//===================================================================
// begin Initialization routines
//
! public BasicComboPopup( JComboBox combo ) {
super();
setName("ComboPopup.popup");
comboBox = combo;
setLightWeightPopupEnabled( comboBox.isLightWeightPopupEnabled() );
--- 317,327 ----
//===================================================================
// begin Initialization routines
//
! public BasicComboPopup( JComboBox<Object> combo ) {
super();
setName("ComboPopup.popup");
comboBox = combo;
setLightWeightPopupEnabled( comboBox.isLightWeightPopupEnabled() );
*** 479,490 ****
* 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() ) {
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();
--- 479,490 ----
* 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<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,618 ****
* <code>uninstallComboBoxModelListeners</code>.
*
* @param model The combo box model to install listeners
* @see #uninstallComboBoxModelListeners
*/
! protected void installComboBoxModelListeners( ComboBoxModel model ) {
if (model != null && (listDataListener = createListDataListener()) != null) {
model.addListDataListener(listDataListener);
}
}
--- 608,618 ----
* <code>uninstallComboBoxModelListeners</code>.
*
* @param model The combo box model to install listeners
* @see #uninstallComboBoxModelListeners
*/
! protected void installComboBoxModelListeners( ComboBoxModel<?> model ) {
if (model != null && (listDataListener = createListDataListener()) != null) {
model.addListDataListener(listDataListener);
}
}
*** 926,941 ****
//
// PropertyChangeListener
//
public void propertyChange(PropertyChangeEvent e) {
! JComboBox comboBox = (JComboBox)e.getSource();
String propertyName = e.getPropertyName();
if ( propertyName == "model" ) {
! ComboBoxModel oldModel = (ComboBoxModel)e.getOldValue();
! ComboBoxModel newModel = (ComboBoxModel)e.getNewValue();
uninstallComboBoxModelListeners(oldModel);
installComboBoxModelListeners(newModel);
list.setModel(newModel);
--- 926,944 ----
//
// PropertyChangeListener
//
public void propertyChange(PropertyChangeEvent e) {
! @SuppressWarnings("unchecked")
! JComboBox<Object> comboBox = (JComboBox)e.getSource();
String propertyName = e.getPropertyName();
if ( propertyName == "model" ) {
! @SuppressWarnings("unchecked")
! ComboBoxModel<Object> oldModel = (ComboBoxModel)e.getOldValue();
! @SuppressWarnings("unchecked")
! ComboBoxModel<Object> newModel = (ComboBoxModel)e.getNewValue();
uninstallComboBoxModelListeners(oldModel);
installComboBoxModelListeners(newModel);
list.setModel(newModel);
*** 953,963 ****
// Pass along the new component orientation
// to the list and the scroller
ComponentOrientation o =(ComponentOrientation)e.getNewValue();
! JList list = getList();
if (list!=null && list.getComponentOrientation()!=o) {
list.setComponentOrientation(o);
}
if (scroller!=null && scroller.getComponentOrientation()!=o) {
--- 956,966 ----
// Pass along the new component orientation
// to the list and the scroller
ComponentOrientation o =(ComponentOrientation)e.getNewValue();
! JList<?> list = getList();
if (list!=null && list.getComponentOrientation()!=o) {
list.setComponentOrientation(o);
}
if (scroller!=null && scroller.getComponentOrientation()!=o) {
*** 976,986 ****
//
// ItemListener
//
public void itemStateChanged( ItemEvent e ) {
if (e.getStateChange() == ItemEvent.SELECTED) {
! JComboBox comboBox = (JComboBox)e.getSource();
setListSelection(comboBox.getSelectedIndex());
}
}
}
--- 979,990 ----
//
// ItemListener
//
public void itemStateChanged( ItemEvent e ) {
if (e.getStateChange() == ItemEvent.SELECTED) {
! @SuppressWarnings("unchecked")
! JComboBox<Object> comboBox = (JComboBox)e.getSource();
setListSelection(comboBox.getSelectedIndex());
}
}
}
*** 1170,1180 ****
*/
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();
Object value = null;
for ( int i = 0; i < minRowCount; ++i ) {
value = list.getModel().getElementAt( i );
Component c = renderer.getListCellRendererComponent( list, value, i, false, false );
--- 1174,1184 ----
*/
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<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 );