104 popupSize.width = Math.max(prefSize.width, popupSize.width); 105 } 106 107 popupSize.width += 10; 108 109 return popupSize; 110 } 111 112 protected boolean shouldScroll() { 113 return comboBox.getItemCount() > comboBox.getMaximumRowCount(); 114 } 115 116 protected boolean isPopdown() { 117 return shouldScroll() || AquaComboBoxUI.isPopdown(comboBox); 118 } 119 120 @Override 121 public void show() { 122 final int startItemCount = comboBox.getItemCount(); 123 124 final Rectangle popupBounds = adjustPopupAndGetBounds(); 125 if (popupBounds == null) return; // null means don't show 126 127 comboBox.firePopupMenuWillBecomeVisible(); 128 show(comboBox, popupBounds.x, popupBounds.y); 129 130 // hack for <rdar://problem/4905531> JComboBox does not fire popupWillBecomeVisible if item count is 0 131 final int afterShowItemCount = comboBox.getItemCount(); 132 if (afterShowItemCount == 0) { 133 hide(); 134 return; 135 } 136 137 if (startItemCount != afterShowItemCount) { 138 final Rectangle newBounds = adjustPopupAndGetBounds(); 139 list.setSize(newBounds.width, newBounds.height); 140 pack(); 141 142 final Point newLoc = comboBox.getLocationOnScreen(); 143 setLocation(newLoc.x + newBounds.x, newLoc.y + newBounds.y); | 104 popupSize.width = Math.max(prefSize.width, popupSize.width); 105 } 106 107 popupSize.width += 10; 108 109 return popupSize; 110 } 111 112 protected boolean shouldScroll() { 113 return comboBox.getItemCount() > comboBox.getMaximumRowCount(); 114 } 115 116 protected boolean isPopdown() { 117 return shouldScroll() || AquaComboBoxUI.isPopdown(comboBox); 118 } 119 120 @Override 121 public void show() { 122 final int startItemCount = comboBox.getItemCount(); 123 124 if (startItemCount == 0) { 125 return; 126 } 127 128 final Rectangle popupBounds = adjustPopupAndGetBounds(); 129 if (popupBounds == null) return; // null means don't show 130 131 comboBox.firePopupMenuWillBecomeVisible(); 132 show(comboBox, popupBounds.x, popupBounds.y); 133 134 // hack for <rdar://problem/4905531> JComboBox does not fire popupWillBecomeVisible if item count is 0 135 final int afterShowItemCount = comboBox.getItemCount(); 136 if (afterShowItemCount == 0) { 137 hide(); 138 return; 139 } 140 141 if (startItemCount != afterShowItemCount) { 142 final Rectangle newBounds = adjustPopupAndGetBounds(); 143 list.setSize(newBounds.width, newBounds.height); 144 pack(); 145 146 final Point newLoc = comboBox.getLocationOnScreen(); 147 setLocation(newLoc.x + newBounds.x, newLoc.y + newBounds.y); |