35 |
obligated to do so. If you do not wish to do so, delete this |
obligated to do so. If you do not wish to do so, delete this |
36 |
exception statement from your version. */ |
exception statement from your version. */ |
37 |
|
|
|
|
|
38 |
package javax.swing; |
package javax.swing; |
39 |
|
|
40 |
|
import java.awt.Component; |
41 |
|
import java.awt.Dimension; |
42 |
import java.awt.ItemSelectable; |
import java.awt.ItemSelectable; |
43 |
import java.awt.event.ActionEvent; |
import java.awt.event.ActionEvent; |
44 |
import java.awt.event.ActionListener; |
import java.awt.event.ActionListener; |
45 |
import java.awt.event.ItemEvent; |
import java.awt.event.ItemEvent; |
46 |
import java.awt.event.ItemListener; |
import java.awt.event.ItemListener; |
47 |
import java.awt.event.KeyEvent; |
import java.awt.event.KeyEvent; |
48 |
|
import java.beans.PropertyChangeEvent; |
49 |
import java.beans.PropertyChangeListener; |
import java.beans.PropertyChangeListener; |
50 |
import java.io.IOException; |
import java.io.IOException; |
51 |
import java.io.ObjectOutputStream; |
import java.io.ObjectOutputStream; |
52 |
import java.util.Vector; |
import java.util.Vector; |
|
|
|
53 |
import javax.accessibility.Accessible; |
import javax.accessibility.Accessible; |
54 |
import javax.accessibility.AccessibleAction; |
import javax.accessibility.AccessibleAction; |
55 |
import javax.accessibility.AccessibleContext; |
import javax.accessibility.AccessibleContext; |
56 |
import javax.accessibility.AccessibleRole; |
import javax.accessibility.AccessibleRole; |
57 |
import javax.accessibility.AccessibleSelection; |
import javax.accessibility.AccessibleSelection; |
58 |
|
import javax.swing.JComponent; |
59 |
import javax.swing.event.ListDataEvent; |
import javax.swing.event.ListDataEvent; |
60 |
import javax.swing.event.ListDataListener; |
import javax.swing.event.ListDataListener; |
61 |
import javax.swing.event.PopupMenuListener; |
import javax.swing.event.PopupMenuListener; |
62 |
import javax.swing.plaf.ComboBoxUI; |
import javax.swing.plaf.ComboBoxUI; |
63 |
|
|
64 |
|
|
65 |
/** |
/** |
66 |
* JComboBox |
* JComboBox. JComboBox is a container, that keeps track of elements added to |
67 |
* @author Andrew Selkirk |
* it by the user. JComboBox allows user to select any item in its list and |
68 |
* @version 1.0 |
* displays the selected item to the user. JComboBox also can show/hide popup |
69 |
|
* menu containing its list of item whenever the mouse is pressed over it. |
70 |
|
* |
71 |
|
* @author Andrew Selkirk |
72 |
|
* @author Olga Rodimina |
73 |
*/ |
*/ |
74 |
public class JComboBox extends JComponent |
public class JComboBox extends JComponent implements ItemSelectable, |
75 |
implements ItemSelectable, ListDataListener, ActionListener, Accessible |
ListDataListener, |
76 |
|
ActionListener, |
77 |
|
Accessible |
78 |
{ |
{ |
79 |
private static final long serialVersionUID = 5654585963292734470L; |
private static final long serialVersionUID = 5654585963292734470L; |
80 |
|
|
81 |
/** |
/** |
82 |
* AccessibleJComboBox |
* KeySelectionManager interface. Class implementing this interface are |
83 |
|
* responsible for matching key characters typed by the user with combo |
84 |
|
* box's items. |
85 |
*/ |
*/ |
86 |
protected class AccessibleJComboBox extends AccessibleJComponent |
public static interface KeySelectionManager |
|
implements AccessibleAction, AccessibleSelection |
|
87 |
{ |
{ |
88 |
private static final long serialVersionUID = 8217828307256675666L; |
int selectionForKey(char aKey, ComboBoxModel aModel); |
89 |
|
} |
90 |
|
|
91 |
|
/** |
92 |
|
* Maximum number of rows that should be visible by default in the |
93 |
|
* JComboBox's popup |
94 |
|
*/ |
95 |
|
public static final int DEFAULT_MAXIMUM_ROW_COUNT = 8; |
96 |
|
|
97 |
|
/** |
98 |
|
* Fired in a PropertyChangeEvent when the 'editable' property changes. |
99 |
|
*/ |
100 |
|
public static final String EDITABLE_CHANGED_PROPERTY = "editable"; |
101 |
|
|
102 |
|
/** |
103 |
|
* Fired in a PropertyChangeEvent when the 'maximumRowCount' property |
104 |
|
* changes. |
105 |
|
*/ |
106 |
|
public static final String MAXIMUM_ROW_COUNT_CHANGED_PROPERTY = "maximumRowCount"; |
107 |
|
|
108 |
|
/** |
109 |
|
* Fired in a PropertyChangeEvent when the 'enabled' property changes. |
110 |
|
*/ |
111 |
|
public static final String ENABLED_CHANGED_PROPERTY = "enabled"; |
112 |
|
|
113 |
|
/** |
114 |
|
* Fired in a PropertyChangeEvent when the 'renderer' property changes. |
115 |
|
*/ |
116 |
|
public static final String RENDERER_CHANGED_PROPERTY = "renderer"; |
117 |
|
|
118 |
|
/** |
119 |
|
* Fired in a PropertyChangeEvent when the 'editor' property changes. |
120 |
|
*/ |
121 |
|
public static final String EDITOR_CHANGED_PROPERTY = "editor"; |
122 |
|
|
123 |
|
/** |
124 |
|
* Fired in a PropertyChangeEvent when the 'dataModel' property changes. |
125 |
|
*/ |
126 |
|
public static final String MODEL_CHANGED_PROPERTY = "dataModel"; |
127 |
|
|
128 |
|
/** |
129 |
|
* name for the UI delegate for this combo box. |
130 |
|
*/ |
131 |
|
private static final String uiClassID = "ComboBoxUI"; |
132 |
|
|
133 |
|
/** |
134 |
|
* dataModel used by JComboBox to keep track of its list data and currently |
135 |
|
* selected element in the list. |
136 |
|
*/ |
137 |
|
protected ComboBoxModel dataModel; |
138 |
|
|
139 |
|
/** |
140 |
|
* Renderer renders(paints) every object in the combo box list in its |
141 |
|
* associated list cell. This ListCellRenderer is used only when this |
142 |
|
* JComboBox is uneditable. |
143 |
|
*/ |
144 |
|
protected ListCellRenderer renderer; |
145 |
|
|
146 |
|
/** |
147 |
|
* editor that is responsible for editting an object in a combo box list |
148 |
|
*/ |
149 |
|
protected ComboBoxEditor editor; |
150 |
|
|
151 |
|
/** |
152 |
|
* Number of rows that will be visible in the JComboBox's popup. |
153 |
|
*/ |
154 |
|
protected int maximumRowCount; |
155 |
|
|
156 |
|
/** |
157 |
|
* This field indicates if textfield of this JComboBox is editable or not. |
158 |
|
*/ |
159 |
|
protected boolean isEditable; |
160 |
|
|
161 |
|
/** |
162 |
|
* This field is reference to the current selection of the combo box. |
163 |
|
*/ |
164 |
|
protected Object selectedItemReminder; |
165 |
|
|
166 |
|
/** |
167 |
|
* keySelectionManager |
168 |
|
*/ |
169 |
|
protected KeySelectionManager keySelectionManager; |
170 |
|
|
171 |
|
/** |
172 |
|
* This actionCommand is used in ActionEvent that is fired to JComboBox's |
173 |
|
* ActionListeneres. |
174 |
|
*/ |
175 |
|
protected String actionCommand; |
176 |
|
|
177 |
|
/** |
178 |
|
* This property indicates if heavyweight popup or lightweight popup will be |
179 |
|
* used to diplay JComboBox's elements. |
180 |
|
*/ |
181 |
|
protected boolean lightWeightPopupEnabled; |
182 |
|
|
183 |
|
/** |
184 |
|
* The action taken when new item is selected in the JComboBox |
185 |
|
*/ |
186 |
|
private Action action; |
187 |
|
|
188 |
|
/** |
189 |
|
* since 1.4 If this field is set then comboBox's display area for the |
190 |
|
* selected item will be set by default to this value. |
191 |
|
*/ |
192 |
|
private Object prototypeDisplayValue; |
193 |
|
|
194 |
|
/** |
195 |
|
* Constructs JComboBox object with specified data model for it. The first |
196 |
|
* item in the specified data model is selected by default. |
197 |
|
* |
198 |
|
* @param model Data model that will be used by this JComboBox to keep track |
199 |
|
* of its list of items. |
200 |
|
*/ |
201 |
|
public JComboBox(ComboBoxModel model) |
202 |
|
{ |
203 |
|
setEditable(false); |
204 |
|
setEnabled(true); |
205 |
|
setMaximumRowCount(DEFAULT_MAXIMUM_ROW_COUNT); |
206 |
|
setModel(model); |
207 |
|
setActionCommand("comboBoxChanged"); |
208 |
|
|
209 |
|
// by default set selected item to the first element in the combo box |
210 |
|
if (getItemCount() != 0) |
211 |
|
setSelectedItem(getItemAt(0)); |
212 |
|
|
213 |
|
lightWeightPopupEnabled = true; |
214 |
|
isEditable = false; |
215 |
|
|
216 |
|
updateUI(); |
217 |
|
} |
218 |
|
|
219 |
|
/** |
220 |
|
* Constructs JComboBox with specified list of items. |
221 |
|
* |
222 |
|
* @param itemArray array containing list of items for this JComboBox |
223 |
|
*/ |
224 |
|
public JComboBox(Object[] itemArray) |
225 |
|
{ |
226 |
|
this(new DefaultComboBoxModel(itemArray)); |
227 |
|
} |
228 |
|
|
229 |
|
/** |
230 |
|
* Constructs JComboBox object with specified list of items. |
231 |
|
* |
232 |
|
* @param itemVector vector containing list of items for this JComboBox. |
233 |
|
*/ |
234 |
|
public JComboBox(Vector itemVector) |
235 |
|
{ |
236 |
|
this(new DefaultComboBoxModel(itemVector)); |
237 |
|
} |
238 |
|
|
239 |
|
/** |
240 |
|
* Constructor. Creates new empty JComboBox. ComboBox's data model is set to |
241 |
|
* DefaultComboBoxModel. |
242 |
|
*/ |
243 |
|
public JComboBox() |
244 |
|
{ |
245 |
|
this(new DefaultComboBoxModel()); |
246 |
|
} |
247 |
|
|
248 |
|
private void writeObject(ObjectOutputStream stream) throws IOException |
249 |
|
{ |
250 |
|
} |
251 |
|
|
252 |
|
/** |
253 |
|
* This method returns true JComboBox is editable and false otherwise |
254 |
|
* |
255 |
|
* @return boolean true if JComboBox is editable and false otherwise |
256 |
|
*/ |
257 |
|
public boolean isEditable() |
258 |
|
{ |
259 |
|
return isEditable; |
260 |
|
} |
261 |
|
|
262 |
/** |
/* |
263 |
* Constructor AccessibleJComboBox |
* This method adds ancestor listener to this JComboBox. |
264 |
* @param component TODO |
*/ |
265 |
|
protected void installAncestorListener() |
266 |
|
{ |
267 |
|
/* FIXME: Need to implement. |
268 |
|
* |
269 |
|
* Need to add ancestor listener to this JComboBox. This listener |
270 |
|
* should close combo box's popup list of items whenever it |
271 |
|
* receives an AncestorEvent. |
272 |
*/ |
*/ |
273 |
protected AccessibleJComboBox() |
} |
274 |
{ |
|
275 |
} |
/** |
276 |
|
* Set the "UI" property of the combo box, which is a look and feel class |
277 |
|
* responsible for handling comboBox's input events and painting it. |
278 |
|
* |
279 |
|
* @param ui The new "UI" property |
280 |
|
*/ |
281 |
|
public void setUI(ComboBoxUI ui) |
282 |
|
{ |
283 |
|
super.setUI(ui); |
284 |
|
} |
285 |
|
|
286 |
|
/** |
287 |
|
* This method sets this comboBox's UI to the UIManager's default for the |
288 |
|
* current look and feel. |
289 |
|
*/ |
290 |
|
public void updateUI() |
291 |
|
{ |
292 |
|
setUI((ComboBoxUI) UIManager.getUI(this)); |
293 |
|
invalidate(); |
294 |
|
} |
295 |
|
|
296 |
|
/** |
297 |
|
* This method returns the String identifier for the UI class to the used |
298 |
|
* with the JComboBox. |
299 |
|
* |
300 |
|
* @return The String identifier for the UI class. |
301 |
|
*/ |
302 |
|
public String getUIClassID() |
303 |
|
{ |
304 |
|
return uiClassID; |
305 |
|
} |
306 |
|
|
307 |
|
/** |
308 |
|
* This method returns the UI used to display the JComboBox. |
309 |
|
* |
310 |
|
* @return The UI used to display the JComboBox. |
311 |
|
*/ |
312 |
|
public ComboBoxUI getUI() |
313 |
|
{ |
314 |
|
return (ComboBoxUI) ui; |
315 |
|
} |
316 |
|
|
317 |
|
/** |
318 |
|
* Set the data model for this JComboBox. This un-registers all listeners |
319 |
|
* associated with the current model, and re-registers them with the new |
320 |
|
* model. |
321 |
|
* |
322 |
|
* @param newDataModel The new data model for this JComboBox |
323 |
|
*/ |
324 |
|
public void setModel(ComboBoxModel newDataModel) |
325 |
|
{ |
326 |
|
if (this.dataModel == newDataModel) |
327 |
|
return; |
328 |
|
|
329 |
|
if (this.dataModel != null) |
330 |
|
// remove all listeners currently registered with the model. |
331 |
|
dataModel.removeListDataListener(this); |
332 |
|
|
333 |
|
ComboBoxModel oldDataModel = this.dataModel; |
334 |
|
this.dataModel = newDataModel; |
335 |
|
|
336 |
|
if (this.dataModel != null) |
337 |
|
// register all listeners with the new data model |
338 |
|
dataModel.addListDataListener(this); |
339 |
|
|
340 |
|
firePropertyChange(MODEL_CHANGED_PROPERTY, oldDataModel, this.dataModel); |
341 |
|
} |
342 |
|
|
343 |
|
/** |
344 |
|
* This method returns data model for this comboBox. |
345 |
|
* |
346 |
|
* @return ComboBoxModel containing items for this combo box. |
347 |
|
*/ |
348 |
|
public ComboBoxModel getModel() |
349 |
|
{ |
350 |
|
return dataModel; |
351 |
|
} |
352 |
|
|
353 |
|
/** |
354 |
|
* This method sets JComboBox's popup to be either lightweight or |
355 |
|
* heavyweight. If 'enabled' is true then lightweight popup is used and |
356 |
|
* heavyweight otherwise. By default lightweight popup is used to display |
357 |
|
* this JComboBox's elements. |
358 |
|
* |
359 |
|
* @param enabled indicates if lightweight popup or heavyweight popup should |
360 |
|
* be used to display JComboBox's elements. |
361 |
|
*/ |
362 |
|
public void setLightWeightPopupEnabled(boolean enabled) |
363 |
|
{ |
364 |
|
this.lightWeightPopupEnabled = enabled; |
365 |
|
} |
366 |
|
|
367 |
|
/** |
368 |
|
* This method returns whether popup menu that is used to display list of |
369 |
|
* combo box's item is lightWeight or not. |
370 |
|
* |
371 |
|
* @return boolean true if popup menu is lightweight and false otherwise. |
372 |
|
*/ |
373 |
|
public boolean isLightWeightPopupEnabled() |
374 |
|
{ |
375 |
|
return lightWeightPopupEnabled; |
376 |
|
} |
377 |
|
|
378 |
|
/** |
379 |
|
* This method sets editability of the combo box. If combo box is editable |
380 |
|
* the user can choose component from the combo box list by typing |
381 |
|
* component's name in the editor(JTextfield by default). Otherwise if not |
382 |
|
* editable, the user should use the list to choose the component. This |
383 |
|
* method fires PropertyChangeEvents to JComboBox's registered |
384 |
|
* PropertyChangeListeners to indicate that 'editable' property of the |
385 |
|
* JComboBox has changed. |
386 |
|
* |
387 |
|
* @param editable indicates if the JComboBox's textfield should be editable |
388 |
|
* or not. |
389 |
|
*/ |
390 |
|
public void setEditable(boolean editable) |
391 |
|
{ |
392 |
|
if (this.isEditable != editable) |
393 |
|
{ |
394 |
|
this.isEditable = editable; |
395 |
|
firePropertyChange(EDITABLE_CHANGED_PROPERTY, ! isEditable, isEditable); |
396 |
|
} |
397 |
|
} |
398 |
|
|
399 |
|
/** |
400 |
|
* Sets number of rows that should be visible in this JComboBox's popup. If |
401 |
|
* this JComboBox's popup has more elements that maximum number or rows |
402 |
|
* then popup will have a scroll pane to allow users to view other |
403 |
|
* elements. |
404 |
|
* |
405 |
|
* @param rowCount number of rows that will be visible in JComboBox's popup. |
406 |
|
*/ |
407 |
|
public void setMaximumRowCount(int rowCount) |
408 |
|
{ |
409 |
|
if (maximumRowCount != rowCount) |
410 |
|
{ |
411 |
|
int oldMaximumRowCount = this.maximumRowCount; |
412 |
|
this.maximumRowCount = rowCount; |
413 |
|
firePropertyChange(MAXIMUM_ROW_COUNT_CHANGED_PROPERTY, |
414 |
|
oldMaximumRowCount, this.maximumRowCount); |
415 |
|
} |
416 |
|
} |
417 |
|
|
418 |
|
/** |
419 |
|
* This method returns number of rows visible in the JComboBox's list of |
420 |
|
* items. |
421 |
|
* |
422 |
|
* @return int maximun number of visible rows in the JComboBox's list. |
423 |
|
*/ |
424 |
|
public int getMaximumRowCount() |
425 |
|
{ |
426 |
|
return maximumRowCount; |
427 |
|
} |
428 |
|
|
429 |
|
/** |
430 |
|
* This method sets cell renderer for this JComboBox that will be used to |
431 |
|
* paint combo box's items. The Renderer should only be used only when |
432 |
|
* JComboBox is not editable. In the case when JComboBox is editable the |
433 |
|
* editor must be used. This method also fires PropertyChangeEvent when |
434 |
|
* cellRendered for this JComboBox has changed. |
435 |
|
* |
436 |
|
* @param aRenderer cell renderer that will be used by this JComboBox to |
437 |
|
* paint its elements. |
438 |
|
*/ |
439 |
|
public void setRenderer(ListCellRenderer aRenderer) |
440 |
|
{ |
441 |
|
if (this.renderer != aRenderer) |
442 |
|
{ |
443 |
|
ListCellRenderer oldRenderer = this.renderer; |
444 |
|
this.renderer = aRenderer; |
445 |
|
firePropertyChange(RENDERER_CHANGED_PROPERTY, oldRenderer, |
446 |
|
this.renderer); |
447 |
|
} |
448 |
|
} |
449 |
|
|
450 |
|
/** |
451 |
|
* This method returns renderer responsible for rendering selected item in |
452 |
|
* the combo box |
453 |
|
* |
454 |
|
* @return ListCellRenderer |
455 |
|
*/ |
456 |
|
public ListCellRenderer getRenderer() |
457 |
|
{ |
458 |
|
return renderer; |
459 |
|
} |
460 |
|
|
461 |
|
/** |
462 |
|
* Sets editor for this JComboBox |
463 |
|
* |
464 |
|
* @param newEditor ComboBoxEditor for this JComboBox. This method fires |
465 |
|
* PropertyChangeEvent when 'editor' property is changed. |
466 |
|
*/ |
467 |
|
public void setEditor(ComboBoxEditor newEditor) |
468 |
|
{ |
469 |
|
if (editor == newEditor) |
470 |
|
return; |
471 |
|
|
472 |
|
if (editor != null) |
473 |
|
editor.removeActionListener(this); |
474 |
|
|
475 |
|
ComboBoxEditor oldEditor = editor; |
476 |
|
editor = newEditor; |
477 |
|
|
478 |
|
if (editor != null) |
479 |
|
editor.addActionListener(this); |
480 |
|
|
481 |
|
firePropertyChange(EDITOR_CHANGED_PROPERTY, oldEditor, editor); |
482 |
|
} |
483 |
|
|
484 |
|
/** |
485 |
|
* Returns editor component that is responsible for displaying/editting |
486 |
|
* selected item in the combo box. |
487 |
|
* |
488 |
|
* @return ComboBoxEditor |
489 |
|
*/ |
490 |
|
public ComboBoxEditor getEditor() |
491 |
|
{ |
492 |
|
return editor; |
493 |
|
} |
494 |
|
|
495 |
|
/** |
496 |
|
* Forces combo box to select given item |
497 |
|
* |
498 |
|
* @param item element in the combo box to select. |
499 |
|
*/ |
500 |
|
public void setSelectedItem(Object item) |
501 |
|
{ |
502 |
|
dataModel.setSelectedItem(item); |
503 |
|
} |
504 |
|
|
505 |
|
/** |
506 |
|
* Returns currently selected item in the combo box. |
507 |
|
* |
508 |
|
* @return element that is currently selected in this combo box. |
509 |
|
*/ |
510 |
|
public Object getSelectedItem() |
511 |
|
{ |
512 |
|
Object item = dataModel.getSelectedItem(); |
513 |
|
|
514 |
|
if (item == null && getItemCount() != 0) |
515 |
|
item = getItemAt(0); |
516 |
|
|
517 |
|
return item; |
518 |
|
} |
519 |
|
|
520 |
|
/** |
521 |
|
* Forces JComboBox to select component located in the given index in the |
522 |
|
* combo box. |
523 |
|
* |
524 |
|
* @param index index specifying location of the component that should be |
525 |
|
* selected. |
526 |
|
*/ |
527 |
|
public void setSelectedIndex(int index) |
528 |
|
{ |
529 |
|
// FIXME: if index == -1 then nothing should be selected |
530 |
|
setSelectedItem(dataModel.getElementAt(index)); |
531 |
|
} |
532 |
|
|
533 |
|
/** |
534 |
|
* Returns index of the item that is currently selected in the combo box. |
535 |
|
* If no item is currently selected, then -1 is returned. |
536 |
|
* |
537 |
|
* @return int index specifying location of the currently selected item in |
538 |
|
* the combo box or -1 if nothing is selected in the combo box. |
539 |
|
*/ |
540 |
|
public int getSelectedIndex() |
541 |
|
{ |
542 |
|
Object selectedItem = getSelectedItem(); |
543 |
|
if (selectedItem != null && (dataModel instanceof DefaultComboBoxModel)) |
544 |
|
return ((DefaultComboBoxModel) dataModel).getIndexOf(selectedItem); |
545 |
|
|
546 |
|
return -1; |
547 |
|
} |
548 |
|
|
549 |
|
public Object getPrototypeDisplayValue() |
550 |
|
{ |
551 |
|
return prototypeDisplayValue; |
552 |
|
} |
553 |
|
|
554 |
|
public void setPrototypeDisplayValue(Object prototypeDisplayValue) |
555 |
|
{ |
556 |
|
this.prototypeDisplayValue = prototypeDisplayValue; |
557 |
|
} |
558 |
|
|
559 |
|
/** |
560 |
|
* This method adds given element to this JComboBox. |
561 |
|
* |
562 |
|
* @param element element to add |
563 |
|
*/ |
564 |
|
public void addItem(Object element) |
565 |
|
{ |
566 |
|
((MutableComboBoxModel) dataModel).addElement(element); |
567 |
|
} |
568 |
|
|
569 |
|
/** |
570 |
|
* Inserts given element at the specified index to this JComboBox |
571 |
|
* |
572 |
|
* @param element element to insert |
573 |
|
* @param index position where to insert the element |
574 |
|
*/ |
575 |
|
public void insertItemAt(Object element, int index) |
576 |
|
{ |
577 |
|
((MutableComboBoxModel) dataModel).insertElementAt(element, index); |
578 |
|
} |
579 |
|
|
580 |
|
/** |
581 |
|
* This method removes given element from this JComboBox. |
582 |
|
* |
583 |
|
* @param element element to remove |
584 |
|
*/ |
585 |
|
public void removeItem(Object element) |
586 |
|
{ |
587 |
|
((MutableComboBoxModel) dataModel).removeElement(element); |
588 |
|
} |
589 |
|
|
590 |
|
/** |
591 |
|
* This method remove element location in the specified index in the |
592 |
|
* JComboBox. |
593 |
|
* |
594 |
|
* @param index index specifying position of the element to remove |
595 |
|
*/ |
596 |
|
public void removeItemAt(int index) |
597 |
|
{ |
598 |
|
((MutableComboBoxModel) dataModel).removeElementAt(index); |
599 |
|
} |
600 |
|
|
601 |
|
/** |
602 |
|
* This method removes all elements from this JComboBox. |
603 |
|
*/ |
604 |
|
public void removeAllItems() |
605 |
|
{ |
606 |
|
if (dataModel instanceof DefaultComboBoxModel) |
607 |
|
((DefaultComboBoxModel) dataModel).removeAllElements(); |
608 |
|
} |
609 |
|
|
610 |
|
/** |
611 |
|
* This method displays popup with list of combo box's items on the screen |
612 |
|
*/ |
613 |
|
public void showPopup() |
614 |
|
{ |
615 |
|
setPopupVisible(true); |
616 |
|
} |
617 |
|
|
618 |
|
/** |
619 |
|
* This method hides popup containing list of combo box's items |
620 |
|
*/ |
621 |
|
public void hidePopup() |
622 |
|
{ |
623 |
|
setPopupVisible(false); |
624 |
|
} |
625 |
|
|
626 |
|
/** |
627 |
|
* This method either displayes or hides the popup containing list of combo |
628 |
|
* box's items. |
629 |
|
* |
630 |
|
* @param visible show popup if 'visible' is true and hide it otherwise |
631 |
|
*/ |
632 |
|
public void setPopupVisible(boolean visible) |
633 |
|
{ |
634 |
|
getUI().setPopupVisible(this, visible); |
635 |
|
} |
636 |
|
|
637 |
|
/** |
638 |
|
* Checks if popup is currently visible on the screen. |
639 |
|
* |
640 |
|
* @return boolean true if popup is visible and false otherwise |
641 |
|
*/ |
642 |
|
public boolean isPopupVisible() |
643 |
|
{ |
644 |
|
return getUI().isPopupVisible(this); |
645 |
|
} |
646 |
|
|
647 |
|
/** |
648 |
|
* This method sets actionCommand to the specified string. ActionEvent fired |
649 |
|
* to this JComboBox registered ActionListeners will contain this |
650 |
|
* actionCommand. |
651 |
|
* |
652 |
|
* @param aCommand new action command for the JComboBox's ActionEvent |
653 |
|
*/ |
654 |
|
public void setActionCommand(String aCommand) |
655 |
|
{ |
656 |
|
actionCommand = aCommand; |
657 |
|
} |
658 |
|
|
659 |
|
/** |
660 |
|
* Returns actionCommand associated with the ActionEvent fired by the |
661 |
|
* JComboBox to its registered ActionListeners. |
662 |
|
* |
663 |
|
* @return String actionCommand for the ActionEvent |
664 |
|
*/ |
665 |
|
public String getActionCommand() |
666 |
|
{ |
667 |
|
return actionCommand; |
668 |
|
} |
669 |
|
|
670 |
|
/** |
671 |
|
* setAction |
672 |
|
* |
673 |
|
* @param a action to set |
674 |
|
*/ |
675 |
|
public void setAction(Action a) |
676 |
|
{ |
677 |
|
Action old = action; |
678 |
|
action = a; |
679 |
|
configurePropertiesFromAction(action); |
680 |
|
if (action != null) |
681 |
|
// FIXME: remove from old action and add to new action |
682 |
|
// PropertyChangeListener to listen to changes in the action |
683 |
|
addActionListener(action); |
684 |
|
} |
685 |
|
|
686 |
|
/** |
687 |
|
* This method returns Action that is invoked when selected item is changed |
688 |
|
* in the JComboBox. |
689 |
|
* |
690 |
|
* @return Action |
691 |
|
*/ |
692 |
|
public Action getAction() |
693 |
|
{ |
694 |
|
return action; |
695 |
|
} |
696 |
|
|
697 |
|
/** |
698 |
|
* Configure properties of the JComboBox by reading properties of specified |
699 |
|
* action. This method always sets the comboBox's "enabled" property to the |
700 |
|
* value of the Action's "enabled" property. |
701 |
|
* |
702 |
|
* @param a An Action to configure the combo box from |
703 |
|
*/ |
704 |
|
protected void configurePropertiesFromAction(Action a) |
705 |
|
{ |
706 |
|
if (a == null) |
707 |
|
{ |
708 |
|
setEnabled(true); |
709 |
|
setToolTipText(null); |
710 |
|
} |
711 |
|
else |
712 |
|
{ |
713 |
|
setEnabled(a.isEnabled()); |
714 |
|
setToolTipText((String) (a.getValue(Action.SHORT_DESCRIPTION))); |
715 |
|
} |
716 |
|
} |
717 |
|
|
718 |
|
/** |
719 |
|
* Creates PropertyChangeListener to listen for the changes in comboBox's |
720 |
|
* action properties. |
721 |
|
* |
722 |
|
* @param action action to listen to for property changes |
723 |
|
* |
724 |
|
* @return $PropertyChangeListener$ Listener that listens to changes in |
725 |
|
* action properties. |
726 |
|
*/ |
727 |
|
protected PropertyChangeListener createActionPropertyChangeListener(Action action) |
728 |
|
{ |
729 |
|
return new PropertyChangeListener() |
730 |
|
{ |
731 |
|
public void propertyChange(PropertyChangeEvent e) |
732 |
|
{ |
733 |
|
Action act = (Action) (e.getSource()); |
734 |
|
configurePropertiesFromAction(act); |
735 |
|
} |
736 |
|
}; |
737 |
|
} |
738 |
|
|
739 |
|
/** |
740 |
|
* This method fires ItemEvent to this JComboBox's registered ItemListeners. |
741 |
|
* This method is invoked when currently selected item in this combo box |
742 |
|
* has changed. |
743 |
|
* |
744 |
|
* @param e the ItemEvent describing the change in the combo box's |
745 |
|
* selection. |
746 |
|
*/ |
747 |
|
protected void fireItemStateChanged(ItemEvent e) |
748 |
|
{ |
749 |
|
ItemListener[] ll = getItemListeners(); |
750 |
|
|
751 |
|
for (int i = 0; i < ll.length; i++) |
752 |
|
ll[i].itemStateChanged(e); |
753 |
|
} |
754 |
|
|
755 |
|
/** |
756 |
|
* This method fires ActionEvent to this JComboBox's registered |
757 |
|
* ActionListeners. This method is invoked when user explicitly changes |
758 |
|
* currently selected item. |
759 |
|
*/ |
760 |
|
protected void fireActionEvent() |
761 |
|
{ |
762 |
|
ActionListener[] ll = getActionListeners(); |
763 |
|
|
764 |
|
for (int i = 0; i < ll.length; i++) |
765 |
|
ll[i].actionPerformed(new ActionEvent(this, |
766 |
|
ActionEvent.ACTION_PERFORMED, |
767 |
|
actionCommand)); |
768 |
|
} |
769 |
|
|
770 |
|
/** |
771 |
|
* This method is invoked whenever selected item changes in the combo box's |
772 |
|
* data model. It fires ItemEvent and ActionEvent to all registered |
773 |
|
* ComboBox's ItemListeners and ActionListeners respectively, indicating |
774 |
|
* the change. |
775 |
|
*/ |
776 |
|
protected void selectedItemChanged() |
777 |
|
{ |
778 |
|
// Fire ItemEvent to indicated that previously selected item is now |
779 |
|
// deselected |
780 |
|
if (selectedItemReminder != null) |
781 |
|
fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED, |
782 |
|
selectedItemReminder, |
783 |
|
ItemEvent.DESELECTED)); |
784 |
|
|
785 |
|
// Fire ItemEvent to indicate that new item is selected |
786 |
|
Object newSelection = getSelectedItem(); |
787 |
|
fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED, |
788 |
|
newSelection, ItemEvent.SELECTED)); |
789 |
|
|
790 |
|
// Fire Action Event to JComboBox's registered listeners |
791 |
|
fireActionEvent(); |
792 |
|
|
793 |
|
selectedItemReminder = newSelection; |
794 |
|
} |
795 |
|
|
796 |
|
/** |
797 |
|
* Returns Object array of size 1 containing currently selected element in |
798 |
|
* the JComboBox. |
799 |
|
* |
800 |
|
* @return Object[] Object array of size 1 containing currently selected |
801 |
|
* element in the JComboBox. |
802 |
|
*/ |
803 |
|
public Object[] getSelectedObjects() |
804 |
|
{ |
805 |
|
Object selectedObject = getSelectedItem(); |
806 |
|
return new Object[] { selectedObject }; |
807 |
|
} |
808 |
|
|
809 |
|
/** |
810 |
|
* This method handles actionEvents fired by the ComboBoxEditor. It changes |
811 |
|
* this JComboBox's selection to the new value currently in the editor and |
812 |
|
* hides list of combo box items. |
813 |
|
* |
814 |
|
* @param e the ActionEvent |
815 |
|
*/ |
816 |
|
public void actionPerformed(ActionEvent e) |
817 |
|
{ |
818 |
|
setSelectedItem(((ComboBoxEditor) e.getSource()).getItem()); |
819 |
|
setPopupVisible(false); |
820 |
|
} |
821 |
|
|
822 |
|
/** |
823 |
|
* This method selects item in this combo box that matches specified |
824 |
|
* specified keyChar and returns true if such item is found. Otherwise |
825 |
|
* false is returned. |
826 |
|
* |
827 |
|
* @param keyChar character indicating which item in the combo box should be |
828 |
|
* selected. |
829 |
|
* |
830 |
|
* @return boolean true if item corresponding to the specified keyChar |
831 |
|
* exists in the combo box. Otherwise false is returned. |
832 |
|
*/ |
833 |
|
public boolean selectWithKeyChar(char keyChar) |
834 |
|
{ |
835 |
|
// FIXME: Need to implement |
836 |
|
return false; |
837 |
|
} |
838 |
|
|
839 |
/** |
/** |
840 |
* getAccessibleChildrenCount |
* The part of implementation of ListDataListener interface. This method is |
841 |
* @returns int |
* invoked when some items where added to the JComboBox's data model. |
842 |
*/ |
* |
843 |
public int getAccessibleChildrenCount() { |
* @param event ListDataEvent describing the change |
844 |
return 0; // TODO |
*/ |
845 |
} // getAccessibleChildrenCount() |
public void intervalAdded(ListDataEvent event) |
846 |
|
{ |
847 |
/** |
// FIXME: Need to implement |
848 |
* getAccessibleChild |
repaint(); |
849 |
* @param value0 TODO |
} |
850 |
* @returns Accessible |
|
851 |
*/ |
/** |
852 |
public Accessible getAccessibleChild(int value0) { |
* The part of implementation of ListDataListener interface. This method is |
853 |
return null; // TODO |
* invoked when some items where removed from the JComboBox's data model. |
854 |
} // getAccessibleChild() |
* |
855 |
|
* @param event ListDataEvent describing the change. |
856 |
/** |
*/ |
857 |
* getAccessibleSelection |
public void intervalRemoved(ListDataEvent event) |
858 |
* @returns AccessibleSelection |
{ |
859 |
*/ |
// FIXME: Need to implement |
860 |
public AccessibleSelection getAccessibleSelection() { |
repaint(); |
861 |
return null; // TODO |
} |
862 |
} // getAccessibleSelection() |
|
863 |
|
/** |
864 |
/** |
* The part of implementation of ListDataListener interface. This method is |
865 |
* getAccessibleSelection |
* invoked when contents of the JComboBox's data model changed. |
866 |
* @param value0 TODO |
* |
867 |
* @returns Accessible |
* @param event ListDataEvent describing the change |
868 |
*/ |
*/ |
869 |
public Accessible getAccessibleSelection(int value0) { |
public void contentsChanged(ListDataEvent event) |
870 |
return null; // TODO |
{ |
871 |
} // getAccessibleSelection() |
// if first and last index of the given ListDataEvent are both -1, |
872 |
|
// then it indicates that selected item in the combo box data model |
873 |
/** |
// have changed. |
874 |
* isAccessibleChildSelected |
if (event.getIndex0() == -1 && event.getIndex1() == -1) |
875 |
* @param value0 TODO |
selectedItemChanged(); |
876 |
* @returns boolean |
} |
|
*/ |
|
|
public boolean isAccessibleChildSelected(int value0) { |
|
|
return false; // TODO |
|
|
} // isAccessibleChildSelected() |
|
|
|
|
|
/** |
|
|
* getAccessibleRole |
|
|
* @returns AccessibleRole |
|
|
*/ |
|
|
public AccessibleRole getAccessibleRole() { |
|
|
return AccessibleRole.COMBO_BOX; |
|
|
} // getAccessibleRole() |
|
|
|
|
|
/** |
|
|
* getAccessibleAction |
|
|
* @returns AccessibleAction |
|
|
*/ |
|
|
public AccessibleAction getAccessibleAction() { |
|
|
return null; // TODO |
|
|
} // getAccessibleAction() |
|
|
|
|
|
/** |
|
|
* getAccessibleActionDescription |
|
|
* @param value0 TODO |
|
|
* @returns String |
|
|
*/ |
|
|
public String getAccessibleActionDescription(int value0) { |
|
|
return null; // TODO |
|
|
} // getAccessibleActionDescription() |
|
|
|
|
|
/** |
|
|
* getAccessibleActionCount |
|
|
* @returns int |
|
|
*/ |
|
|
public int getAccessibleActionCount() { |
|
|
return 0; // TODO |
|
|
} // getAccessibleActionCount() |
|
|
|
|
|
/** |
|
|
* doAccessibleAction |
|
|
* @param value0 TODO |
|
|
* @returns boolean |
|
|
*/ |
|
|
public boolean doAccessibleAction(int value0) { |
|
|
return false; // TODO |
|
|
} // doAccessibleAction() |
|
|
|
|
|
/** |
|
|
* getAccessibleSelectionCount |
|
|
* @returns int |
|
|
*/ |
|
|
public int getAccessibleSelectionCount() { |
|
|
return 0; // TODO |
|
|
} // getAccessibleSelectionCount() |
|
|
|
|
|
/** |
|
|
* addAccessibleSelection |
|
|
* @param value0 TODO |
|
|
*/ |
|
|
public void addAccessibleSelection(int value0) { |
|
|
// TODO |
|
|
} // addAccessibleSelection() |
|
|
|
|
|
/** |
|
|
* removeAccessibleSelection |
|
|
* @param value0 TODO |
|
|
*/ |
|
|
public void removeAccessibleSelection(int value0) { |
|
|
// TODO |
|
|
} // removeAccessibleSelection() |
|
|
|
|
|
/** |
|
|
* clearAccessibleSelection |
|
|
*/ |
|
|
public void clearAccessibleSelection() { |
|
|
// TODO |
|
|
} // clearAccessibleSelection() |
|
|
|
|
|
/** |
|
|
* selectAllAccessibleSelection |
|
|
*/ |
|
|
public void selectAllAccessibleSelection() { |
|
|
// TODO |
|
|
} // selectAllAccessibleSelection() |
|
|
|
|
|
|
|
|
} // AccessibleJComboBox |
|
|
|
|
|
/** |
|
|
* KeySelectionManager |
|
|
*/ |
|
|
public static interface KeySelectionManager { |
|
|
|
|
|
//------------------------------------------------------------- |
|
|
// Methods ---------------------------------------------------- |
|
|
//------------------------------------------------------------- |
|
|
|
|
|
/** |
|
|
* selectionForKey |
|
|
* @param value0 TODO |
|
|
* @param value1 TODO |
|
|
* @returns int |
|
|
*/ |
|
|
int selectionForKey(char value0, ComboBoxModel value1); |
|
|
|
|
|
|
|
|
} // KeySelectionManager |
|
|
|
|
|
|
|
|
//------------------------------------------------------------- |
|
|
// Variables -------------------------------------------------- |
|
|
//------------------------------------------------------------- |
|
|
|
|
|
/** |
|
|
* uiClassID |
|
|
*/ |
|
|
private static final String uiClassID = "ComboBoxUI"; |
|
|
|
|
|
/** |
|
|
* dataModel |
|
|
*/ |
|
|
protected ComboBoxModel dataModel; |
|
|
|
|
|
/** |
|
|
* renderer |
|
|
*/ |
|
|
protected ListCellRenderer renderer; |
|
|
|
|
|
/** |
|
|
* editor |
|
|
*/ |
|
|
protected ComboBoxEditor editor; |
|
|
|
|
|
/** |
|
|
* maximumRowCount |
|
|
*/ |
|
|
protected int maximumRowCount; |
|
|
|
|
|
/** |
|
|
* isEditable |
|
|
*/ |
|
|
protected boolean isEditable; |
|
|
|
|
|
/** |
|
|
* selectedItemReminder |
|
|
*/ |
|
|
protected Object selectedItemReminder; |
|
|
|
|
|
/** |
|
|
* keySelectionManager |
|
|
*/ |
|
|
protected JComboBox.KeySelectionManager keySelectionManager; |
|
|
|
|
|
/** |
|
|
* actionCommand |
|
|
*/ |
|
|
protected String actionCommand; |
|
|
|
|
|
/** |
|
|
* lightWeightPopupEnabled |
|
|
*/ |
|
|
protected boolean lightWeightPopupEnabled; |
|
|
|
|
|
|
|
|
//------------------------------------------------------------- |
|
|
// Initialization --------------------------------------------- |
|
|
//------------------------------------------------------------- |
|
|
|
|
|
/** |
|
|
* Constructor JComboBox |
|
|
* @param value0 TODO |
|
|
*/ |
|
|
public JComboBox(ComboBoxModel value0) { |
|
|
// TODO |
|
|
} // JComboBox() |
|
|
|
|
|
/** |
|
|
* Constructor JComboBox |
|
|
* @param value0 TODO |
|
|
*/ |
|
|
public JComboBox(Object[] value0) { |
|
|
// TODO |
|
|
} // JComboBox() |
|
|
|
|
|
/** |
|
|
* Constructor JComboBox |
|
|
* @param value0 TODO |
|
|
*/ |
|
|
public JComboBox(Vector value0) { |
|
|
// TODO |
|
|
} // JComboBox() |
|
|
|
|
|
/** |
|
|
* Constructor JComboBox |
|
|
*/ |
|
|
public JComboBox() { |
|
|
// TODO |
|
|
} // JComboBox() |
|
|
|
|
|
|
|
|
//------------------------------------------------------------- |
|
|
// Methods ---------------------------------------------------- |
|
|
//------------------------------------------------------------- |
|
|
|
|
|
/** |
|
|
* writeObject |
|
|
* @param stream TODO |
|
|
* @exception IOException TODO |
|
|
*/ |
|
|
private void writeObject(ObjectOutputStream stream) throws IOException { |
|
|
// TODO |
|
|
} // writeObject() |
|
|
|
|
|
/** |
|
|
* isEditable |
|
|
* @returns boolean |
|
|
*/ |
|
|
public boolean isEditable() { |
|
|
return false; // TODO |
|
|
} // isEditable() |
|
|
|
|
|
/** |
|
|
* installAncestorListener |
|
|
*/ |
|
|
protected void installAncestorListener() { |
|
|
// TODO |
|
|
} // installAncestorListener() |
|
|
|
|
|
/** |
|
|
* setUI |
|
|
* @param ui TODO |
|
|
*/ |
|
|
public void setUI(ComboBoxUI ui) { |
|
|
super.setUI(ui); |
|
|
} // setUI() |
|
|
|
|
|
/** |
|
|
* updateUI |
|
|
*/ |
|
|
public void updateUI() { |
|
|
setUI((ComboBoxUI) UIManager.get(this)); |
|
|
invalidate(); |
|
|
} // updateUI() |
|
|
|
|
|
/** |
|
|
* getUIClassID |
|
|
* @returns String |
|
|
*/ |
|
|
public String getUIClassID() { |
|
|
return uiClassID; |
|
|
} // getUIClassID() |
|
|
|
|
|
/** |
|
|
* getUI |
|
|
* @returns ComboBoxUI |
|
|
*/ |
|
|
public ComboBoxUI getUI() { |
|
|
return (ComboBoxUI) ui; |
|
|
} // getUI() |
|
|
|
|
|
/** |
|
|
* setModel |
|
|
* @param value0 TODO |
|
|
*/ |
|
|
public void setModel(ComboBoxModel value0) { |
|
|
// TODO |
|
|
} // setModel() |
|
|
|
|
|
/** |
|
|
* getModel |
|
|
* @returns ComboBoxModel |
|
|
*/ |
|
|
public ComboBoxModel getModel() { |
|
|
return null; // TODO |
|
|
} // getModel() |
|
|
|
|
|
/** |
|
|
* setLightWeightPopupEnabled |
|
|
* @param value0 TODO |
|
|
*/ |
|
|
public void setLightWeightPopupEnabled(boolean value0) { |
|
|
// TODO |
|
|
} // setLightWeightPopupEnabled() |
|
|
|
|
|
/** |
|
|
* isLightWeightPopupEnabled |
|
|
* @returns boolean |
|
|
*/ |
|
|
public boolean isLightWeightPopupEnabled() { |
|
|
return false; // TODO |
|
|
} // isLightWeightPopupEnabled() |
|
|
|
|
|
/** |
|
|
* setEditable |
|
|
* @param value0 TODO |
|
|
*/ |
|
|
public void setEditable(boolean value0) { |
|
|
// TODO |
|
|
} // setEditable() |
|
|
|
|
|
/** |
|
|
* setMaximumRowCount |
|
|
* @param value0 TODO |
|
|
*/ |
|
|
public void setMaximumRowCount(int value0) { |
|
|
// TODO |
|
|
} // setMaximumRowCount() |
|
|
|
|
|
/** |
|
|
* getMaximumRowCount |
|
|
* @returns int |
|
|
*/ |
|
|
public int getMaximumRowCount() { |
|
|
return 0; // TODO |
|
|
} // getMaximumRowCount() |
|
|
|
|
|
/** |
|
|
* setRenderer |
|
|
* @param value0 TODO |
|
|
*/ |
|
|
public void setRenderer(ListCellRenderer value0) { |
|
|
// TODO |
|
|
} // setRenderer() |
|
|
|
|
|
/** |
|
|
* getRenderer |
|
|
* @returns ListCellRenderer |
|
|
*/ |
|
|
public ListCellRenderer getRenderer() { |
|
|
return null; // TODO |
|
|
} // getRenderer() |
|
|
|
|
|
/** |
|
|
* setEditor |
|
|
* @param value0 TODO |
|
|
*/ |
|
|
public void setEditor(ComboBoxEditor value0) { |
|
|
// TODO |
|
|
} // setEditor() |
|
|
|
|
|
/** |
|
|
* getEditor |
|
|
* @returns ComboBoxEditor |
|
|
*/ |
|
|
public ComboBoxEditor getEditor() { |
|
|
return null; // TODO |
|
|
} // getEditor() |
|
|
|
|
|
/** |
|
|
* setSelectedItem |
|
|
* @param value0 TODO |
|
|
*/ |
|
|
public void setSelectedItem(Object value0) { |
|
|
// TODO |
|
|
} // setSelectedItem() |
|
|
|
|
|
/** |
|
|
* getSelectedItem |
|
|
* @returns Object |
|
|
*/ |
|
|
public Object getSelectedItem() { |
|
|
return null; // TODO |
|
|
} // getSelectedItem() |
|
|
|
|
|
/** |
|
|
* setSelectedIndex |
|
|
* @param value0 TODO |
|
|
*/ |
|
|
public void setSelectedIndex(int value0) { |
|
|
// TODO |
|
|
} // setSelectedIndex() |
|
|
|
|
|
/** |
|
|
* getSelectedIndex |
|
|
* @returns int |
|
|
*/ |
|
|
public int getSelectedIndex() { |
|
|
return 0; // TODO |
|
|
} // getSelectedIndex() |
|
|
|
|
|
/** |
|
|
* addItem |
|
|
* @param value0 TODO |
|
|
*/ |
|
|
public void addItem(Object value0) { |
|
|
// TODO |
|
|
} // addItem() |
|
|
|
|
|
/** |
|
|
* insertItemAt |
|
|
* @param value0 TODO |
|
|
* @param value1 TODO |
|
|
*/ |
|
|
public void insertItemAt(Object value0, int value1) { |
|
|
// TODO |
|
|
} // insertItemAt() |
|
|
|
|
|
/** |
|
|
* removeItem |
|
|
* @param value0 TODO |
|
|
*/ |
|
|
public void removeItem(Object value0) { |
|
|
// TODO |
|
|
} // removeItem() |
|
|
|
|
|
/** |
|
|
* removeItemAt |
|
|
* @param value0 TODO |
|
|
*/ |
|
|
public void removeItemAt(int value0) { |
|
|
// TODO |
|
|
} // removeItemAt() |
|
|
|
|
|
/** |
|
|
* removeAllItems |
|
|
*/ |
|
|
public void removeAllItems() { |
|
|
// TODO |
|
|
} // removeAllItems() |
|
|
|
|
|
/** |
|
|
* showPopup |
|
|
*/ |
|
|
public void showPopup() { |
|
|
// TODO |
|
|
} // showPopup() |
|
|
|
|
|
/** |
|
|
* hidePopup |
|
|
*/ |
|
|
public void hidePopup() { |
|
|
// TODO |
|
|
} // hidePopup() |
|
|
|
|
|
/** |
|
|
* setPopupVisible |
|
|
* @param value0 TODO |
|
|
*/ |
|
|
public void setPopupVisible(boolean value0) { |
|
|
// TODO |
|
|
} // setPopupVisible() |
|
|
|
|
|
/** |
|
|
* isPopupVisible |
|
|
* @returns boolean |
|
|
*/ |
|
|
public boolean isPopupVisible() { |
|
|
return false; // TODO |
|
|
} // isPopupVisible() |
|
|
|
|
|
/** |
|
|
* setActionCommand |
|
|
* @param value0 TODO |
|
|
*/ |
|
|
public void setActionCommand(String value0) { |
|
|
// TODO |
|
|
} // setActionCommand() |
|
|
|
|
|
/** |
|
|
* getActionCommand |
|
|
* @returns String |
|
|
*/ |
|
|
public String getActionCommand() { |
|
|
return null; // TODO |
|
|
} // getActionCommand() |
|
|
|
|
|
/** |
|
|
* setAction |
|
|
* @param value0 TODO |
|
|
*/ |
|
|
public void setAction(Action value0) { |
|
|
// TODO |
|
|
} // setAction() |
|
|
|
|
|
/** |
|
|
* isListener |
|
|
* @param value0 TODO |
|
|
* @param value1 TODO |
|
|
* @returns boolean |
|
|
*/ |
|
|
private boolean isListener(Class value0, ActionListener value1) { |
|
|
return false; // TODO |
|
|
} // isListener() |
|
|
|
|
|
/** |
|
|
* getAction |
|
|
* @returns Action |
|
|
*/ |
|
|
public Action getAction() { |
|
|
return null; // TODO |
|
|
} // getAction() |
|
|
|
|
|
/** |
|
|
* configurePropertiesFromAction |
|
|
* @param value0 TODO |
|
|
*/ |
|
|
protected void configurePropertiesFromAction(Action value0) { |
|
|
// TODO |
|
|
} // configurePropertiesFromAction() |
|
|
|
|
|
/** |
|
|
* createActionPropertyChangeListener |
|
|
* @param value0 TODO |
|
|
* @returns PropertyChangeListener |
|
|
*/ |
|
|
protected PropertyChangeListener createActionPropertyChangeListener(Action value0) { |
|
|
return null; // TODO |
|
|
} // createActionPropertyChangeListener() |
|
|
|
|
|
/** |
|
|
* fireItemStateChanged |
|
|
* @param value0 TODO |
|
|
*/ |
|
|
protected void fireItemStateChanged(ItemEvent value0) { |
|
|
// TODO |
|
|
} // fireItemStateChanged() |
|
|
|
|
|
/** |
|
|
* fireActionEvent |
|
|
*/ |
|
|
protected void fireActionEvent() { |
|
|
// TODO |
|
|
} // fireActionEvent() |
|
|
|
|
|
/** |
|
|
* selectedItemChanged |
|
|
*/ |
|
|
protected void selectedItemChanged() { |
|
|
// TODO |
|
|
} // selectedItemChanged() |
|
|
|
|
|
/** |
|
|
* getSelectedObjects |
|
|
* @returns Object[] |
|
|
*/ |
|
|
public Object[] getSelectedObjects() { |
|
|
return null; // TODO |
|
|
} // getSelectedObjects() |
|
|
|
|
|
/** |
|
|
* actionPerformed |
|
|
* @param value0 TODO |
|
|
*/ |
|
|
public void actionPerformed(ActionEvent value0) { |
|
|
// TODO |
|
|
} // actionPerformed() |
|
|
|
|
|
/** |
|
|
* contentsChanged |
|
|
* @param value0 TODO |
|
|
*/ |
|
|
public void contentsChanged(ListDataEvent value0) { |
|
|
// TODO |
|
|
} // contentsChanged() |
|
|
|
|
|
/** |
|
|
* selectWithKeyChar |
|
|
* @param value0 TODO |
|
|
* @returns boolean |
|
|
*/ |
|
|
public boolean selectWithKeyChar(char value0) { |
|
|
return false; // TODO |
|
|
} // selectWithKeyChar() |
|
|
|
|
|
/** |
|
|
* intervalAdded |
|
|
* @param value0 TODO |
|
|
*/ |
|
|
public void intervalAdded(ListDataEvent value0) { |
|
|
// TODO |
|
|
} // intervalAdded() |
|
|
|
|
|
/** |
|
|
* intervalRemoved |
|
|
* @param value0 TODO |
|
|
*/ |
|
|
public void intervalRemoved(ListDataEvent value0) { |
|
|
// TODO |
|
|
} // intervalRemoved() |
|
|
|
|
|
/** |
|
|
* setEnabled |
|
|
* @param value0 TODO |
|
|
*/ |
|
|
public void setEnabled(boolean value0) { |
|
|
// TODO |
|
|
} // setEnabled() |
|
|
|
|
|
/** |
|
|
* configureEditor |
|
|
* @param value0 TODO |
|
|
* @param value1 TODO |
|
|
*/ |
|
|
public void configureEditor(ComboBoxEditor value0, Object value1) { |
|
|
// TODO |
|
|
} // configureEditor() |
|
|
|
|
|
/** |
|
|
* processKeyEvent |
|
|
* @param value0 TODO |
|
|
*/ |
|
|
public void processKeyEvent(KeyEvent value0) { |
|
|
// TODO |
|
|
} // processKeyEvent() |
|
|
|
|
|
/** |
|
|
* isFocusTraversable |
|
|
* @returns boolean |
|
|
* @deprecated |
|
|
*/ |
|
|
public boolean isFocusTraversable() { |
|
|
return false; // TODO |
|
|
} // isFocusTraversable() |
|
|
|
|
|
/** |
|
|
* setKeySelectionManager |
|
|
* @param value0 TODO |
|
|
*/ |
|
|
public void setKeySelectionManager(KeySelectionManager value0) { |
|
|
// TODO |
|
|
} // setKeySelectionManager() |
|
|
|
|
|
/** |
|
|
* getKeySelectionManager |
|
|
* @returns JComboBox.KeySelectionManager |
|
|
*/ |
|
|
public JComboBox.KeySelectionManager getKeySelectionManager() { |
|
|
return null; // TODO |
|
|
} // getKeySelectionManager() |
|
|
|
|
|
/** |
|
|
* getItemCount |
|
|
* @returns int |
|
|
*/ |
|
|
public int getItemCount() { |
|
|
return 0; // TODO |
|
|
} // getItemCount() |
|
|
|
|
|
/** |
|
|
* getItemAt |
|
|
* @param value0 TODO |
|
|
* @returns Object |
|
|
*/ |
|
|
public Object getItemAt(int value0) { |
|
|
return null; // TODO |
|
|
} // getItemAt() |
|
|
|
|
|
/** |
|
|
* createDefaultKeySelectionManager |
|
|
* @returns KeySelectionManager |
|
|
*/ |
|
|
protected KeySelectionManager createDefaultKeySelectionManager() { |
|
|
return null; // TODO |
|
|
} // createDefaultKeySelectionManager() |
|
|
|
|
|
/** |
|
|
* paramString |
|
|
* @returns String |
|
|
*/ |
|
|
protected String paramString() { |
|
|
return null; // TODO |
|
|
} // paramString() |
|
877 |
|
|
878 |
/** |
/** |
879 |
* getAccessibleContext |
* This method disables or enables JComboBox. If the JComboBox is enabled, |
880 |
* @returns AccessibleContext |
* then user is able to make item choice, otherwise if JComboBox is |
881 |
|
* disabled then user is not able to make a selection. |
882 |
|
* |
883 |
|
* @param enabled if 'enabled' is true then enable JComboBox and disable it |
884 |
*/ |
*/ |
885 |
|
public void setEnabled(boolean enabled) |
886 |
|
{ |
887 |
|
boolean oldEnabled = super.isEnabled(); |
888 |
|
if (enabled != oldEnabled) |
889 |
|
{ |
890 |
|
super.setEnabled(enabled); |
891 |
|
firePropertyChange(ENABLED_CHANGED_PROPERTY, oldEnabled, |
892 |
|
(boolean) enabled); |
893 |
|
} |
894 |
|
} |
895 |
|
|
896 |
|
/** |
897 |
|
* This method initializes specified ComboBoxEditor to display given item. |
898 |
|
* |
899 |
|
* @param anEditor ComboBoxEditor to initialize |
900 |
|
* @param anItem Item that should displayed in the specified editor |
901 |
|
*/ |
902 |
|
public void configureEditor(ComboBoxEditor anEditor, Object anItem) |
903 |
|
{ |
904 |
|
anEditor.setItem(anItem); |
905 |
|
} |
906 |
|
|
907 |
|
/** |
908 |
|
* This method hides combo box's popup whenever TAB key is pressed. |
909 |
|
* |
910 |
|
* @param e The KeyEvent indicating which key was pressed. |
911 |
|
*/ |
912 |
|
public void processKeyEvent(KeyEvent e) |
913 |
|
{ |
914 |
|
} |
915 |
|
|
916 |
|
/** |
917 |
|
* This method always returns false to indicate that JComboBox itself is |
918 |
|
* not focus traversable. |
919 |
|
* |
920 |
|
* @return false to indicate that JComboBox itself is not focus traversable. |
921 |
|
* |
922 |
|
* @deprecated |
923 |
|
*/ |
924 |
|
public boolean isFocusTraversable() |
925 |
|
{ |
926 |
|
return false; |
927 |
|
} |
928 |
|
|
929 |
|
/** |
930 |
|
* setKeySelectionManager |
931 |
|
* |
932 |
|
* @param aManager |
933 |
|
*/ |
934 |
|
public void setKeySelectionManager(KeySelectionManager aManager) |
935 |
|
{ |
936 |
|
} |
937 |
|
|
938 |
|
/** |
939 |
|
* getKeySelectionManager |
940 |
|
* |
941 |
|
* @return JComboBox.KeySelectionManager |
942 |
|
*/ |
943 |
|
public KeySelectionManager getKeySelectionManager() |
944 |
|
{ |
945 |
|
return null; |
946 |
|
} |
947 |
|
|
948 |
|
/** |
949 |
|
* This method returns number of elements in this JComboBox |
950 |
|
* |
951 |
|
* @return int number of elements in this JComboBox |
952 |
|
*/ |
953 |
|
public int getItemCount() |
954 |
|
{ |
955 |
|
return ((DefaultComboBoxModel) dataModel).getSize(); |
956 |
|
} |
957 |
|
|
958 |
|
/** |
959 |
|
* Returns elements located in the combo box at the given index. |
960 |
|
* |
961 |
|
* @param index index specifying location of the component to return. |
962 |
|
* |
963 |
|
* @return component in the combo box that is located in the given index. |
964 |
|
*/ |
965 |
|
public Object getItemAt(int index) |
966 |
|
{ |
967 |
|
return ((MutableComboBoxModel) dataModel).getElementAt(index); |
968 |
|
} |
969 |
|
|
970 |
|
/** |
971 |
|
* createDefaultKeySelectionManager |
972 |
|
* |
973 |
|
* @return KeySelectionManager |
974 |
|
*/ |
975 |
|
protected KeySelectionManager createDefaultKeySelectionManager() |
976 |
|
{ |
977 |
|
return null; |
978 |
|
} |
979 |
|
|
980 |
|
/** |
981 |
|
* A string that describes this JComboBox. Normally only used for debugging. |
982 |
|
* |
983 |
|
* @return A string describing this JComboBox |
984 |
|
*/ |
985 |
|
protected String paramString() |
986 |
|
{ |
987 |
|
return "JComboBox"; |
988 |
|
} |
989 |
|
|
990 |
public AccessibleContext getAccessibleContext() |
public AccessibleContext getAccessibleContext() |
991 |
{ |
{ |
992 |
if (accessibleContext == null) |
if (accessibleContext == null) |
994 |
|
|
995 |
return accessibleContext; |
return accessibleContext; |
996 |
} |
} |
997 |
|
|
998 |
/** |
/** |
999 |
* addActionListener |
* This methods adds specified ActionListener to this JComboBox. |
1000 |
* @param listener TODO |
* |
1001 |
|
* @param listener to add |
1002 |
*/ |
*/ |
1003 |
public void addActionListener (ActionListener listener) |
public void addActionListener(ActionListener listener) |
1004 |
{ |
{ |
1005 |
listenerList.add (ActionListener.class, listener); |
listenerList.add(ActionListener.class, listener); |
1006 |
} |
} |
1007 |
|
|
1008 |
/** |
/** |
1009 |
* removeActionListener |
* This method removes specified ActionListener from this JComboBox. |
1010 |
* @param listener TODO |
* |
1011 |
|
* @param listener ActionListener |
1012 |
*/ |
*/ |
1013 |
public void removeActionListener (ActionListener listener) |
public void removeActionListener(ActionListener listener) |
1014 |
{ |
{ |
1015 |
listenerList.remove (ActionListener.class, listener); |
listenerList.remove(ActionListener.class, listener); |
1016 |
} |
} |
1017 |
|
|
1018 |
/** |
/** |
1019 |
|
* This method returns array of ActionListeners that are registered with |
1020 |
|
* this JComboBox. |
1021 |
|
* |
1022 |
* @since 1.4 |
* @since 1.4 |
1023 |
*/ |
*/ |
1024 |
public ActionListener[] getActionListeners() |
public ActionListener[] getActionListeners() |
1025 |
{ |
{ |
1026 |
return (ActionListener[]) getListeners (ActionListener.class); |
return (ActionListener[]) getListeners(ActionListener.class); |
1027 |
} |
} |
1028 |
|
|
1029 |
/** |
/** |
1030 |
* addItemListener |
* This method registers given ItemListener with this JComboBox |
1031 |
* @param listener TODO |
* |
1032 |
|
* @param listener to remove |
1033 |
*/ |
*/ |
1034 |
public void addItemListener(ItemListener listener) |
public void addItemListener(ItemListener listener) |
1035 |
{ |
{ |
1036 |
listenerList.add (ItemListener.class, listener); |
listenerList.add(ItemListener.class, listener); |
1037 |
} |
} |
1038 |
|
|
1039 |
/** |
/** |
1040 |
* removeItemListener |
* This method unregisters given ItemListener from this JComboBox |
1041 |
* @param listener TODO |
* |
1042 |
|
* @param listener to remove |
1043 |
*/ |
*/ |
1044 |
public void removeItemListener(ItemListener listener) |
public void removeItemListener(ItemListener listener) |
1045 |
{ |
{ |
1046 |
listenerList.remove (ItemListener.class, listener); |
listenerList.remove(ItemListener.class, listener); |
1047 |
} |
} |
1048 |
|
|
1049 |
/** |
/** |
1050 |
|
* This method returns array of ItemListeners that are registered with this |
1051 |
|
* JComboBox. |
1052 |
|
* |
1053 |
* @since 1.4 |
* @since 1.4 |
1054 |
*/ |
*/ |
1055 |
public ItemListener[] getItemListeners() |
public ItemListener[] getItemListeners() |
1056 |
{ |
{ |
1057 |
return (ItemListener[]) getListeners (ItemListener.class); |
return (ItemListener[]) getListeners(ItemListener.class); |
1058 |
} |
} |
1059 |
|
|
1060 |
public void addPopupMenuListener (PopupMenuListener listener) |
/** |
1061 |
|
* Adds PopupMenuListener to combo box to listen to the events fired by the |
1062 |
|
* combo box's popup menu containing its list of items |
1063 |
|
* |
1064 |
|
* @param listener to add |
1065 |
|
*/ |
1066 |
|
public void addPopupMenuListener(PopupMenuListener listener) |
1067 |
{ |
{ |
1068 |
listenerList.add (PopupMenuListener.class, listener); |
listenerList.add(PopupMenuListener.class, listener); |
1069 |
} |
} |
1070 |
|
|
1071 |
public void removePopupMenuListener (PopupMenuListener listener) |
/** |
1072 |
|
* Removes PopupMenuListener to combo box to listen to the events fired by |
1073 |
|
* the combo box's popup menu containing its list of items |
1074 |
|
* |
1075 |
|
* @param listener to add |
1076 |
|
*/ |
1077 |
|
public void removePopupMenuListener(PopupMenuListener listener) |
1078 |
{ |
{ |
1079 |
listenerList.remove (PopupMenuListener.class, listener); |
listenerList.remove(PopupMenuListener.class, listener); |
1080 |
} |
} |
1081 |
|
|
1082 |
/** |
/** |
1083 |
* @since 1.4 |
* Returns array of PopupMenuListeners that are registered with combo box. |
1084 |
*/ |
*/ |
1085 |
public PopupMenuListener[] getPopupMenuListeners() |
public PopupMenuListener[] getPopupMenuListeners() |
1086 |
{ |
{ |
1087 |
return (PopupMenuListener[]) getListeners (PopupMenuListener.class); |
return (PopupMenuListener[]) getListeners(PopupMenuListener.class); |
1088 |
|
} |
1089 |
|
|
1090 |
|
/** |
1091 |
|
* AccessibleJComboBox |
1092 |
|
*/ |
1093 |
|
protected class AccessibleJComboBox extends AccessibleJComponent |
1094 |
|
implements AccessibleAction, AccessibleSelection |
1095 |
|
{ |
1096 |
|
private static final long serialVersionUID = 8217828307256675666L; |
1097 |
|
|
1098 |
|
protected AccessibleJComboBox() |
1099 |
|
{ |
1100 |
|
} |
1101 |
|
|
1102 |
|
public int getAccessibleChildrenCount() |
1103 |
|
{ |
1104 |
|
return 0; |
1105 |
|
} |
1106 |
|
|
1107 |
|
public Accessible getAccessibleChild(int value0) |
1108 |
|
{ |
1109 |
|
return null; |
1110 |
|
} |
1111 |
|
|
1112 |
|
public AccessibleSelection getAccessibleSelection() |
1113 |
|
{ |
1114 |
|
return null; |
1115 |
|
} |
1116 |
|
|
1117 |
|
public Accessible getAccessibleSelection(int value0) |
1118 |
|
{ |
1119 |
|
return null; |
1120 |
|
} |
1121 |
|
|
1122 |
|
public boolean isAccessibleChildSelected(int value0) |
1123 |
|
{ |
1124 |
|
return false; |
1125 |
|
} |
1126 |
|
|
1127 |
|
public AccessibleRole getAccessibleRole() |
1128 |
|
{ |
1129 |
|
return AccessibleRole.COMBO_BOX; |
1130 |
|
} |
1131 |
|
|
1132 |
|
public AccessibleAction getAccessibleAction() |
1133 |
|
{ |
1134 |
|
return null; |
1135 |
|
} |
1136 |
|
|
1137 |
|
public String getAccessibleActionDescription(int value0) |
1138 |
|
{ |
1139 |
|
return null; |
1140 |
|
} |
1141 |
|
|
1142 |
|
public int getAccessibleActionCount() |
1143 |
|
{ |
1144 |
|
return 0; |
1145 |
|
} |
1146 |
|
|
1147 |
|
public boolean doAccessibleAction(int value0) |
1148 |
|
{ |
1149 |
|
return false; |
1150 |
|
} |
1151 |
|
|
1152 |
|
public int getAccessibleSelectionCount() |
1153 |
|
{ |
1154 |
|
return 0; |
1155 |
|
} |
1156 |
|
|
1157 |
|
public void addAccessibleSelection(int value0) |
1158 |
|
{ |
1159 |
|
} |
1160 |
|
|
1161 |
|
public void removeAccessibleSelection(int value0) |
1162 |
|
{ |
1163 |
|
} |
1164 |
|
|
1165 |
|
public void clearAccessibleSelection() |
1166 |
|
{ |
1167 |
|
} |
1168 |
|
|
1169 |
|
public void selectAllAccessibleSelection() |
1170 |
|
{ |
1171 |
|
} |
1172 |
} |
} |
1173 |
} |
} |