511 protected ItemListener createItemListener() {
512 return getHandler();
513 }
514
515 private Handler getHandler() {
516 if (handler == null) {
517 handler = new Handler();
518 }
519 return handler;
520 }
521
522 /**
523 * Creates the JList used in the popup to display
524 * the items in the combo box model. This method is called when the UI class
525 * is created.
526 *
527 * @return a <code>JList</code> used to display the combo box items
528 */
529 protected JList<Object> createList() {
530 return new JList<Object>( comboBox.getModel() ) {
531 public void processMouseEvent(MouseEvent e) {
532 if (BasicGraphicsUtils.isMenuShortcutKeyDown(e)) {
533 // Fix for 4234053. Filter out the Control Key from the list.
534 // ie., don't allow CTRL key deselection.
535 Toolkit toolkit = Toolkit.getDefaultToolkit();
536 e = new MouseEvent((Component)e.getSource(), e.getID(), e.getWhen(),
537 e.getModifiers() ^ toolkit.getMenuShortcutKeyMask(),
538 e.getX(), e.getY(),
539 e.getXOnScreen(), e.getYOnScreen(),
540 e.getClickCount(),
541 e.isPopupTrigger(),
542 MouseEvent.NOBUTTON);
543 }
544 super.processMouseEvent(e);
545 }
546 };
547 }
548
549 /**
550 * Configures the list which is used to hold the combo box items in the
1221 */
1222 private void setListSelection(int selectedIndex) {
1223 if ( selectedIndex == -1 ) {
1224 list.clearSelection();
1225 }
1226 else {
1227 list.setSelectedIndex( selectedIndex );
1228 list.ensureIndexIsVisible( selectedIndex );
1229 }
1230 }
1231
1232 /**
1233 * Converts mouse event.
1234 *
1235 * @param e a mouse event
1236 * @return converted mouse event
1237 */
1238 protected MouseEvent convertMouseEvent( MouseEvent e ) {
1239 Point convertedPoint = SwingUtilities.convertPoint( (Component)e.getSource(),
1240 e.getPoint(), list );
1241 MouseEvent newEvent = new MouseEvent( (Component)e.getSource(),
1242 e.getID(),
1243 e.getWhen(),
1244 e.getModifiers(),
1245 convertedPoint.x,
1246 convertedPoint.y,
1247 e.getXOnScreen(),
1248 e.getYOnScreen(),
1249 e.getClickCount(),
1250 e.isPopupTrigger(),
1251 MouseEvent.NOBUTTON );
1252 return newEvent;
1253 }
1254
1255
1256 /**
1257 * Retrieves the height of the popup based on the current
1258 * ListCellRenderer and the maximum row count.
1259 *
1260 * @param maxRowCount the row count
|
511 protected ItemListener createItemListener() {
512 return getHandler();
513 }
514
515 private Handler getHandler() {
516 if (handler == null) {
517 handler = new Handler();
518 }
519 return handler;
520 }
521
522 /**
523 * Creates the JList used in the popup to display
524 * the items in the combo box model. This method is called when the UI class
525 * is created.
526 *
527 * @return a <code>JList</code> used to display the combo box items
528 */
529 protected JList<Object> createList() {
530 return new JList<Object>( comboBox.getModel() ) {
531 @SuppressWarnings("deprecation")
532 public void processMouseEvent(MouseEvent e) {
533 if (BasicGraphicsUtils.isMenuShortcutKeyDown(e)) {
534 // Fix for 4234053. Filter out the Control Key from the list.
535 // ie., don't allow CTRL key deselection.
536 Toolkit toolkit = Toolkit.getDefaultToolkit();
537 e = new MouseEvent((Component)e.getSource(), e.getID(), e.getWhen(),
538 e.getModifiers() ^ toolkit.getMenuShortcutKeyMask(),
539 e.getX(), e.getY(),
540 e.getXOnScreen(), e.getYOnScreen(),
541 e.getClickCount(),
542 e.isPopupTrigger(),
543 MouseEvent.NOBUTTON);
544 }
545 super.processMouseEvent(e);
546 }
547 };
548 }
549
550 /**
551 * Configures the list which is used to hold the combo box items in the
1222 */
1223 private void setListSelection(int selectedIndex) {
1224 if ( selectedIndex == -1 ) {
1225 list.clearSelection();
1226 }
1227 else {
1228 list.setSelectedIndex( selectedIndex );
1229 list.ensureIndexIsVisible( selectedIndex );
1230 }
1231 }
1232
1233 /**
1234 * Converts mouse event.
1235 *
1236 * @param e a mouse event
1237 * @return converted mouse event
1238 */
1239 protected MouseEvent convertMouseEvent( MouseEvent e ) {
1240 Point convertedPoint = SwingUtilities.convertPoint( (Component)e.getSource(),
1241 e.getPoint(), list );
1242 @SuppressWarnings("deprecation")
1243 MouseEvent newEvent = new MouseEvent( (Component)e.getSource(),
1244 e.getID(),
1245 e.getWhen(),
1246 e.getModifiers(),
1247 convertedPoint.x,
1248 convertedPoint.y,
1249 e.getXOnScreen(),
1250 e.getYOnScreen(),
1251 e.getClickCount(),
1252 e.isPopupTrigger(),
1253 MouseEvent.NOBUTTON );
1254 return newEvent;
1255 }
1256
1257
1258 /**
1259 * Retrieves the height of the popup based on the current
1260 * ListCellRenderer and the maximum row count.
1261 *
1262 * @param maxRowCount the row count
|