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


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

Re: ActionEvent Generator

Path csiph.com!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Jerry Stuckle <jstucklex@attglobal.net>
Newsgroups comp.lang.java.programmer
Subject Re: ActionEvent Generator
Date Mon, 02 Feb 2015 09:43:51 -0500
Organization A noiseless patient Spider
Lines 51
Message-ID <mao2e6$gpq$3@dont-email.me> (permalink)
References <mamhh8$q6r$1@dont-email.me> <mamjq3$gkh$1@news2.informatik.uni-stuttgart.de>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 7bit
Injection-Date Mon, 2 Feb 2015 14:43:18 +0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="3088393e34bc61b3e6a923d0c81ae1e3"; logging-data="17210"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Ud/ohADut1d0HhX6DJyLcDaEL2OZrzlo="
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0
In-Reply-To <mamjq3$gkh$1@news2.informatik.uni-stuttgart.de>
Cancel-Lock sha1:xZKcypslMo5mEQbyZhaBAt/dVRE=
Xref csiph.com comp.lang.java.programmer:31014

Show key headers only | 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