137 }
138
139 if (startItemCount != afterShowItemCount) {
140 final Rectangle newBounds = adjustPopupAndGetBounds();
141 list.setSize(newBounds.width, newBounds.height);
142 pack();
143
144 final Point newLoc = comboBox.getLocationOnScreen();
145 setLocation(newLoc.x + newBounds.x, newLoc.y + newBounds.y);
146 }
147 // end hack
148
149 list.requestFocusInWindow();
150 }
151
152 @Override
153 @SuppressWarnings("serial") // anonymous class
154 protected JList<Object> createList() {
155 return new JList<Object>(comboBox.getModel()) {
156 @Override
157 public void processMouseEvent(MouseEvent e) {
158 if (e.isMetaDown()) {
159 e = new MouseEvent((Component)e.getSource(), e.getID(), e.getWhen(), e.getModifiers() ^ InputEvent.META_MASK, e.getX(), e.getY(), e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), MouseEvent.NOBUTTON);
160 }
161 super.processMouseEvent(e);
162 }
163 };
164 }
165
166 protected Rectangle adjustPopupAndGetBounds() {
167 if (isPopDown != isPopdown()) {
168 updateContents(true);
169 }
170
171 final Dimension popupSize = getBestPopupSizeForRowCount(comboBox.getMaximumRowCount());
172 final Rectangle popupBounds = computePopupBounds(0, comboBox.getBounds().height, popupSize.width, popupSize.height);
173 if (popupBounds == null) return null; // returning null means don't show anything
174
175 final Dimension realPopupSize = popupBounds.getSize();
176 scroller.setMaximumSize(realPopupSize);
177 scroller.setPreferredSize(realPopupSize);
178 scroller.setMinimumSize(realPopupSize);
179 list.invalidate();
|
137 }
138
139 if (startItemCount != afterShowItemCount) {
140 final Rectangle newBounds = adjustPopupAndGetBounds();
141 list.setSize(newBounds.width, newBounds.height);
142 pack();
143
144 final Point newLoc = comboBox.getLocationOnScreen();
145 setLocation(newLoc.x + newBounds.x, newLoc.y + newBounds.y);
146 }
147 // end hack
148
149 list.requestFocusInWindow();
150 }
151
152 @Override
153 @SuppressWarnings("serial") // anonymous class
154 protected JList<Object> createList() {
155 return new JList<Object>(comboBox.getModel()) {
156 @Override
157 @SuppressWarnings("deprecation")
158 public void processMouseEvent(MouseEvent e) {
159 if (e.isMetaDown()) {
160 e = new MouseEvent((Component) e.getSource(), e.getID(),
161 e.getWhen(),
162 e.getModifiers() ^ InputEvent.META_MASK,
163 e.getX(), e.getY(), e.getXOnScreen(),
164 e.getYOnScreen(), e.getClickCount(),
165 e.isPopupTrigger(), MouseEvent.NOBUTTON);
166 }
167 super.processMouseEvent(e);
168 }
169 };
170 }
171
172 protected Rectangle adjustPopupAndGetBounds() {
173 if (isPopDown != isPopdown()) {
174 updateContents(true);
175 }
176
177 final Dimension popupSize = getBestPopupSizeForRowCount(comboBox.getMaximumRowCount());
178 final Rectangle popupBounds = computePopupBounds(0, comboBox.getBounds().height, popupSize.width, popupSize.height);
179 if (popupBounds == null) return null; // returning null means don't show anything
180
181 final Dimension realPopupSize = popupBounds.getSize();
182 scroller.setMaximumSize(realPopupSize);
183 scroller.setPreferredSize(realPopupSize);
184 scroller.setMinimumSize(realPopupSize);
185 list.invalidate();
|