< prev index next >

## src/java.desktop/macosx/classes/sun/lwawt/LWChoicePeer.java

Print this page

    rev 48858 : Work in progress for JDK-6303622
    Use generic in Swing components like JComboBox
    1. Added generic return type and parameter type for JComboBox.
    2. Modified JList related classes as well.
    3. Reverted the changes made to "getSelectedValues" as suggested by Joe.
    4. Modified files that were failing on Linux and Mac as well.

     140         JComboBoxDelegate() {
     141             super();
     142         }
     143
     144         @Override
     145         public boolean hasFocus() {
     146             return getTarget().hasFocus();
     147         }
     148
     149         //Needed for proper popup menu location
     150         @Override
     151         public Point getLocationOnScreen() {
     152             return LWChoicePeer.this.getLocationOnScreen();
     153         }
     154
     155         /**
     156          * We should post ITEM_STATE_CHANGED event when the same element is
     157          * reselected.
     158          */
     159         @Override
     160         public void setSelectedItem(final Object anObject) {
     161             final Object oldSelection = selectedItemReminder;
     162             if (oldSelection != null && oldSelection.equals(anObject)) {
     163                 selectedItemChanged();
     164             }
     165             super.setSelectedItem(anObject);
     166         }
     167
     168         @Override
     169         public void firePopupMenuWillBecomeVisible() {
     170             super.firePopupMenuWillBecomeVisible();
     171             SwingUtilities.invokeLater(() -> {
     172                 JPopupMenu popupMenu = getPopupMenu();
     173                 // Need to override the invoker for proper grab handling
     174                 if (popupMenu != null
     175                         && popupMenu.isShowing()
     176                         && popupMenu.getInvoker() != getTarget()) {
     177                     // The popup is now visible with correct location
     178                     // Save it and restore after toggling visibility and changing invoker
     179                     Point loc = popupMenu.getLocationOnScreen();
     180                     SwingUtilities.convertPointFromScreen(loc, this);
     181                     popupMenu.setVisible(false);
     140         JComboBoxDelegate() {
     141             super();
     142         }
     143
     144         @Override
     145         public boolean hasFocus() {
     146             return getTarget().hasFocus();
     147         }
     148
     149         //Needed for proper popup menu location
     150         @Override
     151         public Point getLocationOnScreen() {
     152             return LWChoicePeer.this.getLocationOnScreen();
     153         }
     154
     155         /**
     156          * We should post ITEM_STATE_CHANGED event when the same element is
     157          * reselected.
     158          */
     159         @Override
     160         public void setSelectedItem(final String anObject) {
     161             final String oldSelection = selectedItemReminder;
     162             if (oldSelection != null && oldSelection.equals(anObject)) {
     163                 selectedItemChanged();
     164             }
     165             super.setSelectedItem(anObject);
     166         }
     167
     168         @Override
     169         public void firePopupMenuWillBecomeVisible() {
     170             super.firePopupMenuWillBecomeVisible();
     171             SwingUtilities.invokeLater(() -> {
     172                 JPopupMenu popupMenu = getPopupMenu();
     173                 // Need to override the invoker for proper grab handling
     174                 if (popupMenu != null
     175                         && popupMenu.isShowing()
     176                         && popupMenu.getInvoker() != getTarget()) {
     177                     // The popup is now visible with correct location
     178                     // Save it and restore after toggling visibility and changing invoker
     179                     Point loc = popupMenu.getLocationOnScreen();
     180                     SwingUtilities.convertPointFromScreen(loc, this);
     181                     popupMenu.setVisible(false);

< prev index next >