Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #31014

Re: ActionEvent Generator

From Jerry Stuckle <jstucklex@attglobal.net>
Newsgroups comp.lang.java.programmer
Subject Re: ActionEvent Generator
Date 2015-02-02 09:43 -0500
Organization A noiseless patient Spider
Message-ID <mao2e6$gpq$3@dont-email.me> (permalink)
References <mamhh8$q6r$1@dont-email.me> <mamjq3$gkh$1@news2.informatik.uni-stuttgart.de>

Show all headers | View raw


On 2/1/2015 8:27 PM, Thomas Richter wrote:
> On 02.02.2015 01:49, Jerry Stuckle wrote:
>> Hi, all,
>>
>> I have a need to generate an ActionEvent to drive handlers, and am
>> having trouble finding examples.  It doesn't seem to be as easy as a
>> PropertyChangeEvent, for which there are multiple examples.  I've also
>> looked at some of the Java source code and it seems somewhat convoluted.
>>
>> I don't need something real fancy - just the ability to generate an
>> ActionEvent in my object and have it passed to the handlers.  Can anyone
>> point me to some example code showing an easy way to do this?
> 
> It's actually quite trivial. You create a new ActionEvent() with
> 
> ActionEvent ev = new ActionEvent(...);
> 
> and then have a list of actionListeners, for example in your class as an
> arraylist
> 
> ArrayList<ActionListener> alist = new ArrayList<ActionListener>();
> 
> and simply iterate over the list, calling actionPerformed() for each
> listener:
> 
> for(al : alist) {
>     al.actionPerformed(ev);
> }
> 
> Done. It's really that trivial.
> 
> Greetings,
>     Thomas
> 
> 

Thomas,

Hmmm, this is just too easy! :)  I looked through a lot of code, i.e.
Node, MenuItem and several others, and the code looked much more complex.

Of course I'll need to add a few extra methods, but this gets me on the
right track and I think I can handle the rest.  Thanks!


-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

ActionEvent Generator Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-01 19:49 -0500
  Re: ActionEvent Generator Thomas Richter <thor@math.tu-berlin.de> - 2015-02-02 02:27 +0100
    Re: ActionEvent Generator Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-02 09:43 -0500
  Re: ActionEvent Generator Jeff Higgins <jeff@invalid.invalid> - 2015-02-01 20:30 -0500
    Re: ActionEvent Generator Jeff Higgins <jeff@invalid.invalid> - 2015-02-02 07:38 -0500
      Re: ActionEvent Generator Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-02 09:41 -0500
    Re: ActionEvent Generator Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-02 09:40 -0500
  Re: ActionEvent Generator Joerg Meier <joergmmeier@arcor.de> - 2015-02-02 08:40 +0100
    Re: ActionEvent Generator Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-02 09:57 -0500

csiph-web