206 protected int scrollDirection = SCROLL_UP;
207
208 /**
209 * The direction of scrolling up.
210 */
211 protected static final int SCROLL_UP = 0;
212
213 /**
214 * The direction of scrolling down.
215 */
216 protected static final int SCROLL_DOWN = 1;
217
218
219 //========================================
220 // begin ComboPopup method implementations
221 //
222
223 /**
224 * Implementation of ComboPopup.show().
225 */
226 public void show() {
227 comboBox.firePopupMenuWillBecomeVisible();
228 setListSelection(comboBox.getSelectedIndex());
229 Point location = getPopupLocation();
230 show( comboBox, location.x, location.y );
231 }
232
233
234 /**
235 * Implementation of ComboPopup.hide().
236 */
237 public void hide() {
238 MenuSelectionManager manager = MenuSelectionManager.defaultManager();
239 MenuElement [] selection = manager.getSelectedPath();
240 for ( int i = 0 ; i < selection.length ; i++ ) {
241 if ( selection[i] == this ) {
242 manager.clearSelectedPath();
243 break;
244 }
245 }
246 if (selection.length > 0) {
247 comboBox.repaint();
248 }
249 }
250
251 /**
252 * Implementation of ComboPopup.getList().
253 */
254 public JList<Object> getList() {
255 return list;
256 }
1015 //
1016 // ItemListener
1017 //
1018 public void itemStateChanged( ItemEvent e ) {
1019 if (e.getStateChange() == ItemEvent.SELECTED) {
1020 @SuppressWarnings("unchecked")
1021 JComboBox<Object> comboBox = (JComboBox)e.getSource();
1022 setListSelection(comboBox.getSelectedIndex());
1023 }
1024 }
1025 }
1026
1027 //
1028 // end Event Listeners
1029 //=================================================================
1030
1031
1032 /**
1033 * Overridden to unconditionally return false.
1034 */
1035 public boolean isFocusTraversable() {
1036 return false;
1037 }
1038
1039 //===================================================================
1040 // begin Autoscroll methods
1041 //
1042
1043 /**
1044 * This protected method is implementation specific and should be private.
1045 * do not call or override.
1046 *
1047 * @param direction the direction of scrolling
1048 */
1049 protected void startAutoScrolling( int direction ) {
1050 // XXX - should be a private method within InvocationMouseMotionHandler
1051 // if possible.
1052 if ( isAutoScrolling ) {
1053 autoscrollTimer.stop();
1054 }
|
206 protected int scrollDirection = SCROLL_UP;
207
208 /**
209 * The direction of scrolling up.
210 */
211 protected static final int SCROLL_UP = 0;
212
213 /**
214 * The direction of scrolling down.
215 */
216 protected static final int SCROLL_DOWN = 1;
217
218
219 //========================================
220 // begin ComboPopup method implementations
221 //
222
223 /**
224 * Implementation of ComboPopup.show().
225 */
226 @SuppressWarnings("deprecation")
227 public void show() {
228 comboBox.firePopupMenuWillBecomeVisible();
229 setListSelection(comboBox.getSelectedIndex());
230 Point location = getPopupLocation();
231 show( comboBox, location.x, location.y );
232 }
233
234
235 /**
236 * Implementation of ComboPopup.hide().
237 */
238 @SuppressWarnings("deprecation")
239 public void hide() {
240 MenuSelectionManager manager = MenuSelectionManager.defaultManager();
241 MenuElement [] selection = manager.getSelectedPath();
242 for ( int i = 0 ; i < selection.length ; i++ ) {
243 if ( selection[i] == this ) {
244 manager.clearSelectedPath();
245 break;
246 }
247 }
248 if (selection.length > 0) {
249 comboBox.repaint();
250 }
251 }
252
253 /**
254 * Implementation of ComboPopup.getList().
255 */
256 public JList<Object> getList() {
257 return list;
258 }
1017 //
1018 // ItemListener
1019 //
1020 public void itemStateChanged( ItemEvent e ) {
1021 if (e.getStateChange() == ItemEvent.SELECTED) {
1022 @SuppressWarnings("unchecked")
1023 JComboBox<Object> comboBox = (JComboBox)e.getSource();
1024 setListSelection(comboBox.getSelectedIndex());
1025 }
1026 }
1027 }
1028
1029 //
1030 // end Event Listeners
1031 //=================================================================
1032
1033
1034 /**
1035 * Overridden to unconditionally return false.
1036 */
1037 @SuppressWarnings("deprecation")
1038 public boolean isFocusTraversable() {
1039 return false;
1040 }
1041
1042 //===================================================================
1043 // begin Autoscroll methods
1044 //
1045
1046 /**
1047 * This protected method is implementation specific and should be private.
1048 * do not call or override.
1049 *
1050 * @param direction the direction of scrolling
1051 */
1052 protected void startAutoScrolling( int direction ) {
1053 // XXX - should be a private method within InvocationMouseMotionHandler
1054 // if possible.
1055 if ( isAutoScrolling ) {
1056 autoscrollTimer.stop();
1057 }
|