309 * {@inheritDoc}
310 */
311 public void removeChangeListener(ChangeListener l) {
312 listenerList.remove(ChangeListener.class, l);
313 }
314
315 /**
316 * Returns an array of all the change listeners
317 * registered on this <code>DefaultButtonModel</code>.
318 *
319 * @return all of this model's <code>ChangeListener</code>s
320 * or an empty
321 * array if no change listeners are currently registered
322 *
323 * @see #addChangeListener
324 * @see #removeChangeListener
325 *
326 * @since 1.4
327 */
328 public ChangeListener[] getChangeListeners() {
329 return (ChangeListener[])listenerList.getListeners(
330 ChangeListener.class);
331 }
332
333 /**
334 * Notifies all listeners that have registered interest for
335 * notification on this event type. The event instance
336 * is created lazily.
337 *
338 * @see EventListenerList
339 */
340 protected void fireStateChanged() {
341 // Guaranteed to return a non-null array
342 Object[] listeners = listenerList.getListenerList();
343 // Process the listeners last to first, notifying
344 // those that are interested in this event
345 for (int i = listeners.length-2; i>=0; i-=2) {
346 if (listeners[i]==ChangeListener.class) {
347 // Lazily create the event:
348 if (changeEvent == null)
349 changeEvent = new ChangeEvent(this);
350 ((ChangeListener)listeners[i+1]).stateChanged(changeEvent);
363 * {@inheritDoc}
364 */
365 public void removeActionListener(ActionListener l) {
366 listenerList.remove(ActionListener.class, l);
367 }
368
369 /**
370 * Returns an array of all the action listeners
371 * registered on this <code>DefaultButtonModel</code>.
372 *
373 * @return all of this model's <code>ActionListener</code>s
374 * or an empty
375 * array if no action listeners are currently registered
376 *
377 * @see #addActionListener
378 * @see #removeActionListener
379 *
380 * @since 1.4
381 */
382 public ActionListener[] getActionListeners() {
383 return (ActionListener[])listenerList.getListeners(
384 ActionListener.class);
385 }
386
387 /**
388 * Notifies all listeners that have registered interest for
389 * notification on this event type.
390 *
391 * @param e the <code>ActionEvent</code> to deliver to listeners
392 * @see EventListenerList
393 */
394 protected void fireActionPerformed(ActionEvent e) {
395 // Guaranteed to return a non-null array
396 Object[] listeners = listenerList.getListenerList();
397 // Process the listeners last to first, notifying
398 // those that are interested in this event
399 for (int i = listeners.length-2; i>=0; i-=2) {
400 if (listeners[i]==ActionListener.class) {
401 // Lazily create the event:
402 // if (changeEvent == null)
403 // changeEvent = new ChangeEvent(this);
404 ((ActionListener)listeners[i+1]).actionPerformed(e);
417 * {@inheritDoc}
418 */
419 public void removeItemListener(ItemListener l) {
420 listenerList.remove(ItemListener.class, l);
421 }
422
423 /**
424 * Returns an array of all the item listeners
425 * registered on this <code>DefaultButtonModel</code>.
426 *
427 * @return all of this model's <code>ItemListener</code>s
428 * or an empty
429 * array if no item listeners are currently registered
430 *
431 * @see #addItemListener
432 * @see #removeItemListener
433 *
434 * @since 1.4
435 */
436 public ItemListener[] getItemListeners() {
437 return (ItemListener[])listenerList.getListeners(ItemListener.class);
438 }
439
440 /**
441 * Notifies all listeners that have registered interest for
442 * notification on this event type.
443 *
444 * @param e the <code>ItemEvent</code> to deliver to listeners
445 * @see EventListenerList
446 */
447 protected void fireItemStateChanged(ItemEvent e) {
448 // Guaranteed to return a non-null array
449 Object[] listeners = listenerList.getListenerList();
450 // Process the listeners last to first, notifying
451 // those that are interested in this event
452 for (int i = listeners.length-2; i>=0; i-=2) {
453 if (listeners[i]==ItemListener.class) {
454 // Lazily create the event:
455 // if (changeEvent == null)
456 // changeEvent = new ChangeEvent(this);
457 ((ItemListener)listeners[i+1]).itemStateChanged(e);
|
309 * {@inheritDoc}
310 */
311 public void removeChangeListener(ChangeListener l) {
312 listenerList.remove(ChangeListener.class, l);
313 }
314
315 /**
316 * Returns an array of all the change listeners
317 * registered on this <code>DefaultButtonModel</code>.
318 *
319 * @return all of this model's <code>ChangeListener</code>s
320 * or an empty
321 * array if no change listeners are currently registered
322 *
323 * @see #addChangeListener
324 * @see #removeChangeListener
325 *
326 * @since 1.4
327 */
328 public ChangeListener[] getChangeListeners() {
329 return listenerList.getListeners(ChangeListener.class);
330 }
331
332 /**
333 * Notifies all listeners that have registered interest for
334 * notification on this event type. The event instance
335 * is created lazily.
336 *
337 * @see EventListenerList
338 */
339 protected void fireStateChanged() {
340 // Guaranteed to return a non-null array
341 Object[] listeners = listenerList.getListenerList();
342 // Process the listeners last to first, notifying
343 // those that are interested in this event
344 for (int i = listeners.length-2; i>=0; i-=2) {
345 if (listeners[i]==ChangeListener.class) {
346 // Lazily create the event:
347 if (changeEvent == null)
348 changeEvent = new ChangeEvent(this);
349 ((ChangeListener)listeners[i+1]).stateChanged(changeEvent);
362 * {@inheritDoc}
363 */
364 public void removeActionListener(ActionListener l) {
365 listenerList.remove(ActionListener.class, l);
366 }
367
368 /**
369 * Returns an array of all the action listeners
370 * registered on this <code>DefaultButtonModel</code>.
371 *
372 * @return all of this model's <code>ActionListener</code>s
373 * or an empty
374 * array if no action listeners are currently registered
375 *
376 * @see #addActionListener
377 * @see #removeActionListener
378 *
379 * @since 1.4
380 */
381 public ActionListener[] getActionListeners() {
382 return listenerList.getListeners(ActionListener.class);
383 }
384
385 /**
386 * Notifies all listeners that have registered interest for
387 * notification on this event type.
388 *
389 * @param e the <code>ActionEvent</code> to deliver to listeners
390 * @see EventListenerList
391 */
392 protected void fireActionPerformed(ActionEvent e) {
393 // Guaranteed to return a non-null array
394 Object[] listeners = listenerList.getListenerList();
395 // Process the listeners last to first, notifying
396 // those that are interested in this event
397 for (int i = listeners.length-2; i>=0; i-=2) {
398 if (listeners[i]==ActionListener.class) {
399 // Lazily create the event:
400 // if (changeEvent == null)
401 // changeEvent = new ChangeEvent(this);
402 ((ActionListener)listeners[i+1]).actionPerformed(e);
415 * {@inheritDoc}
416 */
417 public void removeItemListener(ItemListener l) {
418 listenerList.remove(ItemListener.class, l);
419 }
420
421 /**
422 * Returns an array of all the item listeners
423 * registered on this <code>DefaultButtonModel</code>.
424 *
425 * @return all of this model's <code>ItemListener</code>s
426 * or an empty
427 * array if no item listeners are currently registered
428 *
429 * @see #addItemListener
430 * @see #removeItemListener
431 *
432 * @since 1.4
433 */
434 public ItemListener[] getItemListeners() {
435 return listenerList.getListeners(ItemListener.class);
436 }
437
438 /**
439 * Notifies all listeners that have registered interest for
440 * notification on this event type.
441 *
442 * @param e the <code>ItemEvent</code> to deliver to listeners
443 * @see EventListenerList
444 */
445 protected void fireItemStateChanged(ItemEvent e) {
446 // Guaranteed to return a non-null array
447 Object[] listeners = listenerList.getListenerList();
448 // Process the listeners last to first, notifying
449 // those that are interested in this event
450 for (int i = listeners.length-2; i>=0; i-=2) {
451 if (listeners[i]==ItemListener.class) {
452 // Lazily create the event:
453 // if (changeEvent == null)
454 // changeEvent = new ChangeEvent(this);
455 ((ItemListener)listeners[i+1]).itemStateChanged(e);
|