468 * Returns an array of all the <code>ActionListener</code>s added
469 * to this JTextField with addActionListener().
470 *
471 * @return all of the <code>ActionListener</code>s added or an empty
472 * array if no listeners have been added
473 * @since 1.4
474 */
475 @BeanProperty(bound = false)
476 public synchronized ActionListener[] getActionListeners() {
477 return listenerList.getListeners(ActionListener.class);
478 }
479
480 /**
481 * Notifies all listeners that have registered interest for
482 * notification on this event type. The event instance
483 * is lazily created.
484 * The listener list is processed in last to
485 * first order.
486 * @see EventListenerList
487 */
488 protected void fireActionPerformed() {
489 // Guaranteed to return a non-null array
490 Object[] listeners = listenerList.getListenerList();
491 int modifiers = 0;
492 AWTEvent currentEvent = EventQueue.getCurrentEvent();
493 if (currentEvent instanceof InputEvent) {
494 modifiers = ((InputEvent)currentEvent).getModifiers();
495 } else if (currentEvent instanceof ActionEvent) {
496 modifiers = ((ActionEvent)currentEvent).getModifiers();
497 }
498 ActionEvent e =
499 new ActionEvent(this, ActionEvent.ACTION_PERFORMED,
500 (command != null) ? command : getText(),
501 EventQueue.getMostRecentEventTime(), modifiers);
502
503 // Process the listeners last to first, notifying
504 // those that are interested in this event
505 for (int i = listeners.length-2; i>=0; i-=2) {
506 if (listeners[i]==ActionListener.class) {
507 ((ActionListener)listeners[i+1]).actionPerformed(e);
|
468 * Returns an array of all the <code>ActionListener</code>s added
469 * to this JTextField with addActionListener().
470 *
471 * @return all of the <code>ActionListener</code>s added or an empty
472 * array if no listeners have been added
473 * @since 1.4
474 */
475 @BeanProperty(bound = false)
476 public synchronized ActionListener[] getActionListeners() {
477 return listenerList.getListeners(ActionListener.class);
478 }
479
480 /**
481 * Notifies all listeners that have registered interest for
482 * notification on this event type. The event instance
483 * is lazily created.
484 * The listener list is processed in last to
485 * first order.
486 * @see EventListenerList
487 */
488 @SuppressWarnings("deprecation")
489 protected void fireActionPerformed() {
490 // Guaranteed to return a non-null array
491 Object[] listeners = listenerList.getListenerList();
492 int modifiers = 0;
493 AWTEvent currentEvent = EventQueue.getCurrentEvent();
494 if (currentEvent instanceof InputEvent) {
495 modifiers = ((InputEvent)currentEvent).getModifiers();
496 } else if (currentEvent instanceof ActionEvent) {
497 modifiers = ((ActionEvent)currentEvent).getModifiers();
498 }
499 ActionEvent e =
500 new ActionEvent(this, ActionEvent.ACTION_PERFORMED,
501 (command != null) ? command : getText(),
502 EventQueue.getMostRecentEventTime(), modifiers);
503
504 // Process the listeners last to first, notifying
505 // those that are interested in this event
506 for (int i = listeners.length-2; i>=0; i-=2) {
507 if (listeners[i]==ActionListener.class) {
508 ((ActionListener)listeners[i+1]).actionPerformed(e);
|