src/macosx/classes/com/apple/laf/AquaComboBoxUI.java

Print this page




 505     @SuppressWarnings("serial") // anonymous class
 506     private static final Action toggleSelectionAction = new AbstractAction() {
 507         public void actionPerformed(final ActionEvent e) {
 508             final JComboBox comboBox = (JComboBox)e.getSource();
 509             if (!comboBox.isEnabled()) return;
 510             if (comboBox.isEditable()) return;
 511 
 512             final AquaComboBoxUI aquaUi = (AquaComboBoxUI)comboBox.getUI();
 513 
 514             if (comboBox.isPopupVisible()) {
 515                 comboBox.setSelectedIndex(aquaUi.getPopup().getList().getSelectedIndex());
 516                 comboBox.setPopupVisible(false);
 517                 return;
 518             }
 519 
 520             comboBox.setPopupVisible(true);
 521         }
 522     };
 523 
 524     @SuppressWarnings("serial") // anonymous class
 525     private static Action hideAction = new AbstractAction() {
 526         @Override
 527         public void actionPerformed(final ActionEvent e) {
 528             final JComboBox comboBox = (JComboBox)e.getSource();
 529 
 530             if (comboBox.isPopupVisible()) {
 531                 comboBox.firePopupMenuCanceled();
 532                 comboBox.setPopupVisible(false);
 533             }




 534         }
 535     };
 536 
 537     public void applySizeFor(final JComponent c, final Size size) {
 538         if (arrowButton == null) return;
 539         final Border border = arrowButton.getBorder();
 540         if (!(border instanceof AquaButtonBorder)) return;
 541         final AquaButtonBorder aquaBorder = (AquaButtonBorder)border;
 542         arrowButton.setBorder(aquaBorder.deriveBorderForSize(size));
 543     }
 544 
 545     public Dimension getMinimumSize(final JComponent c) {
 546         if (!isMinimumSizeDirty) {
 547             return new Dimension(cachedMinimumSize);
 548         }
 549 
 550         final boolean editable = comboBox.isEditable();
 551 
 552         final Dimension size;
 553         if (!editable && arrowButton != null && arrowButton instanceof AquaComboBoxButton) {




 505     @SuppressWarnings("serial") // anonymous class
 506     private static final Action toggleSelectionAction = new AbstractAction() {
 507         public void actionPerformed(final ActionEvent e) {
 508             final JComboBox comboBox = (JComboBox)e.getSource();
 509             if (!comboBox.isEnabled()) return;
 510             if (comboBox.isEditable()) return;
 511 
 512             final AquaComboBoxUI aquaUi = (AquaComboBoxUI)comboBox.getUI();
 513 
 514             if (comboBox.isPopupVisible()) {
 515                 comboBox.setSelectedIndex(aquaUi.getPopup().getList().getSelectedIndex());
 516                 comboBox.setPopupVisible(false);
 517                 return;
 518             }
 519 
 520             comboBox.setPopupVisible(true);
 521         }
 522     };
 523 
 524     @SuppressWarnings("serial") // anonymous class
 525     private final Action hideAction = new AbstractAction() {
 526         @Override
 527         public void actionPerformed(final ActionEvent e) {
 528             final JComboBox comboBox = (JComboBox)e.getSource();


 529             comboBox.firePopupMenuCanceled();
 530             comboBox.setPopupVisible(false);
 531         }
 532 
 533         @Override
 534         public boolean isEnabled() {
 535             return comboBox.isPopupVisible() && super.isEnabled();
 536         }
 537     };
 538 
 539     public void applySizeFor(final JComponent c, final Size size) {
 540         if (arrowButton == null) return;
 541         final Border border = arrowButton.getBorder();
 542         if (!(border instanceof AquaButtonBorder)) return;
 543         final AquaButtonBorder aquaBorder = (AquaButtonBorder)border;
 544         arrowButton.setBorder(aquaBorder.deriveBorderForSize(size));
 545     }
 546 
 547     public Dimension getMinimumSize(final JComponent c) {
 548         if (!isMinimumSizeDirty) {
 549             return new Dimension(cachedMinimumSize);
 550         }
 551 
 552         final boolean editable = comboBox.isEditable();
 553 
 554         final Dimension size;
 555         if (!editable && arrowButton != null && arrowButton instanceof AquaComboBoxButton) {