Order of execution for event listeners..??

Hi there,
Looking at the JDK source, I see that all classes that generate events, iterate through the listeners in reverse order. What is more, they start at size - 2. I am first, confused as to why it goes in this direction, and second, why size - 2 is used. Does the last added one not get called?
As for reverse order, the problem I see with this is if a class that implements a listener in one way, then you want to add a listener, but your listener code depends on something being done within the first listener. For example, I created a simple file selection component. On the left is all files. On the right is the selected files. The component works fine. You can dbl-click a file to move it, or click the > or >> (or < or <<) to move selected files or ALL files in one direction or the other. The problem is, my component implements the ActionListener of the > and >> buttons. I made it public so that classes using this component could also add listeners. The main reason is, in the case of a "wizad", you do NOT want the NEXT button to be enabled until at least one selected file is in the right list box. So, when I add the listener, the component listener does NOT get called before my newly added listener. That listener does the job of moving the file and redisplaying the list of all files and selected files. But since my listener gets called first, that is not done, therefore the "selected" files list is NOT yet updated based on the button clicked. I am guessing that this occurs because of the reverse execution of listeners, and my listener is added after the component listener.
So, is there any way to reverse this without having to reimplement the list myself? I'd hate to extend JButton just to handle executing listeners in the order they are added. Seems silly to me that this is not at least an optional boolean choice to indicate the direction to execute listeners, but I sure would love to know why Sun has gone this direction.
Thanks.

Thanks for the reply.
That seems very odd to me, that it puts two entries per one listener. So let me ask you this, is this so that it can store the listeners in a list, but also store the type of listener? While at first this seems an odd way to use a list, I have come across several times when I wish I could store two objects in the list as one. I thus have created an inner class taking the two objects (usually a String for a "key" and an object), and then stored that in the list. The reson is, I want to store MORE than one of the same type, so a Set is out of the question, but a list only adds one object. I wish there was a class that allowed multiple values stored under the same key. I guess this would be easy enough to create, but it seems like something so often used that the JDK would have this in it already. Unless I am mistaken, I have not seen any Collection implementec class that can have multiple keys, and each key can have multiple values. Have you? So, I take it, just to verify, that the reason for storing the class type, then the actual instance is just this reason..to figure out the type it is, then the actual object that implements it (the reference to it).
Thanks.

Similar Messages

  • Order of Execution for TreeSelectionListener

    Hi,
    I have a JTree on which I have registered 2 separate TreeSelectionListeners A and then B. I thought they would by default execute in a first-in first-out way, such as firstly A, secondly B, but to my surprise when I change a selection, listener B executes first!. As far as I have read, the only way to attain listener A executing first, is to re-register the listeners in the desired order when I register listener B.
    Am I correct? Is this the only way? Looks weird that the API doesn't preview this case.
    Thanks for your help,
    Chal.lo.

    As far as I have read, the only way to attain listener A executing first, is to re-register the listeners in the desired orderWherever you might have read that, it's not correct. From
    [Java AWT: Delegation Event Model|http://java.sun.com/j2se/1.3/docs/guide/awt/designspec/events.html]
    (about a third of the way down the page)
    The API makes no guarantees about the order in which the events are delivered to a set of registered listeners for a given event on a given source.
    In the same paragraph:
    If the order in which events are delivered to listeners is a factor for your program, you should chain the listeners off a single listener which is registered on the source (the fact that the event data is encapsulated in a single object makes propagating the event extremely simple).
    db

  • How to block execution of event listeners

    Hi all,
    JDev version : 11.1.1.6
    My requirement is that I want to block all event listeners like ActionListeners, SelectionListeners, DisclosureListeners, RowDisclosure listeners when the screen is opened in readonly mode.
    I could block ActionListeners by disabling command links and command buttons etc.
    But there's no way to block SelectionListeners, DisclosureListeners, RowDisclosure listeners.
    So Is there any common code which can block all listeners?
    Or is there any EventController or something like that which will allow me to control event execution?

    I would have if it was just one screen.
    There are hundreds of screens.
    Anyways, can't I use any javascript to do this? There are some interfaces like EventListeners , classes like EventConsumer etc. Do none of them provide feature to block event listeners?

  • Order of execution for various Nodes in HANA Views

    Hello Folks,
    I have created some analytic and calculation views. I would like to know order of execution of various nodes inside them such as Logical Join, Data Foundation, Semantics for Analytic views.

    And to find out how to use planviz:
    Show me the timelines, baby! by Lars himself
    Ravi

  • Statechart Module: What is the order of execution for a parent state and its substates?

    Hello,
    This page describes the order of execution of transitions and actions for one level of nesting. What about compound states? Do the static reactions of the parent state execute before the transitions of the sub-states?

    Hello, 
    I'm not incredibly familiar with the Statechart module, but I will look into it for you on our internal database. In the mean time, there are some examples that may answer some of your questions here:
    https://decibel.ni.com/content/docs/DOC-8716
    and here:
    http://www.ni.com/white-paper/7425/en
    -N
    National Instruments
    Applications Engineer

  • 8.1 did not sort the sort order for events in photos app

    With 7000 photos in more than 300 events You must have them in alphabetic order as before in 7.1 The pictures are synced from iMac iPhoto. How to do a search. The events are not found by names

    When I drag albums into the correct order in Photos for Mac, they show up in reverse order on the iOS devices. Thus there seems to be a bug in either iOS 8.3, OS 10.10.3 or iCloud Photo Library.
    The browser version of iCloud Photo Library (icloud.com) is currently updating. I am waiting to see which way my albums are sorted there.
    There is no promise at all, or documented anywhere, how sorting of library items will sync across the devices. This has been haphazard when syncing iPhoto Libraries - synced faces not sorted, synced events  not sorted, etc. So it is at least a step in the right direction, in Photos that the albums are sorted at all.

  • Documentation for custom event listeners

    Hi,
    I am searching in portal 8.1 documents for using custom events, coding and registering event listeners, and using them in jsp pages. So far my search has been unsuccessful.
    Can some one let me know where i find this info?
    -thanks

    Hi J, 
    Thanks for your reply.
    I didn’t find the custom work item Web Access control Official documents, but you can refer to the information in these articles(it’s same in TFS 2013):
    http://blogs.msdn.com/b/serkani/archive/2012/06/22/work-item-custom-control-development-in-tf-web-access-2012-development.aspx
    http://blogs.msdn.com/b/serkani/archive/2012/06/22/work-item-custom-control-development-in-tf-web-access-2012-deployment.aspx
    For how to debug TFS Web Access Extensions, please refer to:
    http://www.alexandervanwynsberghe.be/debugging-tfs-web-access-customizations/.
    For the custom work item Web Access control Official documents, you can
    submit it to User Voice site at: http://visualstudio.uservoice.com/forums/121579-visual-studio. Microsoft engineers will evaluate them seriously.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • [svn:osmf:] 15000: Fix for FM-447 : Adding CuePoint in TemporalFacet event listeners doesn't work

    Revision: 15000
    Revision: 15000
    Author:   [email protected]
    Date:     2010-03-24 14:01:02 -0700 (Wed, 24 Mar 2010)
    Log Message:
    Fix for FM-447 : Adding CuePoint in TemporalFacet event listeners doesn't work
    Ticket Links:
        http://bugs.adobe.com/jira/browse/FM-447
    Modified Paths:
        osmf/trunk/framework/OSMF/org/osmf/metadata/TimelineMetadata.as

  • [svn:osmf:] 14975: Fix for FM-447 : Adding CuePoint in TemporalFacet event listeners doesn't work

    Revision: 14975
    Revision: 14975
    Author:   [email protected]
    Date:     2010-03-23 17:04:43 -0700 (Tue, 23 Mar 2010)
    Log Message:
    Fix for FM-447 : Adding CuePoint in TemporalFacet event listeners doesn't work
    Ticket Links:
        http://bugs.adobe.com/jira/browse/FM-447
    Modified Paths:
        osmf/trunk/framework/OSMF/org/osmf/metadata/TimelineMetadata.as

  • Order of execution of named method user properties and server script

    Dear All,
    If for a Custom method on an applet, we have scripts in WebApplet_preinvokemethod and WebApplet_invokemethod and also for the same Custom method we have applet Named Method user properties and BC Named Method user properties, what will be the order of execution of these scripts and Named Method user properties??

    The Private Event Submission sample portlet shows how to achieve this. It is part of the PDK download.
    Peter

  • Actionscript 3 - Multiple variables for event listener.

    Ok, I have a question (of course that is the reason why I am here).  I have been focusing on PHP a lot lately and just had a client that requires an MP3 player playing multiple songs so I had to whip out my rusty actionscript skills.  I have the player completed and it is working as desired.  The down side is it has multiple songs.  I am using separate functions for each song and separate event listeners.  My main question is there a way to combine these funtions into one and just use the event listener to pass another variable to the functions?  Below is a sample of one of the code for Song1.  I would like to make it so anywhere there is Song1 in the code, I can make it a variable so I can put in for example (Song2, Song3, Song4, etc.)  This way, I can have one or two functions handle all the songs instead of having to copy, paste and then find and replace.
    Thanks for the help!
    // Song 1
    var Song1:Sound = new Sound();
    pbSong1.source = Song1;
    //pbSong1.visible = false;
    var Song1Loaded:Boolean = false;
    pbSong1.addEventListener(Event.COMPLETE, Song1LoadComplete);
    btnSong1Play.addEventListener(MouseEvent.CLICK, Song1Play);
    btnSong1Stop.addEventListener(MouseEvent.CLICK, Stop);
    function Song1Play(event:MouseEvent) {
         if (Song1Loaded == true) {
              sndchnlMain.stop();
              sndchnlMain = Song1.play();
         } else {
              pbSong1.visible = true;
              Song1.load(new URLRequest("media/music/Song1.mp3"));
    function Song1LoadComplete(event:Event) {
         trace("Size of file: " + Song1.bytesTotal);
         Song1.close();
         Song1Loaded = true;
         if(sndchnlMain) {
              sndchnlMain.stop();
         sndchnlMain = Song1.play();
         pbSong1.visible = false;

    But if I reset the bolean to false, if the visitor goes to replay that song, it will try to load the song again.  I did find away around having to the use the boolean value though and accomplish the same thing (I am loving this).  I am using:
    this["Song"+SongNum].bytesTotal
    If there are bytes, then the song is loaded OR loading.  In order to check if the song is completely loaded before it plays, I am using this:
    this["Song"+SongNum].bytesTotal == this["Song"+SongNum].bytesLoaded
    This elimates the need for the Boolean I was using.  Also instead of for each song defining:
    pbSong1.source = Song1;
    I am using the main function to do it for me:
    this["pbSong"+SongNum].source = this["Song"+SongNum];
    The reason why I asked about the Sound variable, I was currious if I could do the same with it as I did with the Progress Bar Source as shown above?  Instead of defining this first:
    var Song1:Sound = new Sound();
    Can I do this in the function:
    var this["Song"+SongNum]:Sound = new Sound();
    I tried it once but I got an error.
    Here is the new FULL updated code:
    import fl.controls.ProgressBar;
    import flash.events.ProgressEvent;
    import flash.events.IOErrorEvent;
    import flash.net.URLRequest;
    import flash.media.SoundChannel;
    import flash.media.Sound;
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.display.MovieClip;
    var sndchnlMain:SoundChannel;
    ClearNowPlaying();
      Song 1 Definitions
    var Song1:Sound = new Sound();
    pbSong1.addEventListener(Event.COMPLETE, LoadComplete);
    btnSong1Play.addEventListener(MouseEvent.CLICK, PlaySong);
    btnSong1Stop.addEventListener(MouseEvent.CLICK, Stop);
      Song 2 Definitions
    var Song2:Sound = new Sound();
    pbSong2.addEventListener(Event.COMPLETE, LoadComplete);
    btnSong2Play.addEventListener(MouseEvent.CLICK, PlaySong);
    btnSong2Stop.addEventListener(MouseEvent.CLICK, Stop);
      Song 3 Definitions
    var Song3:Sound = new Sound();
    pbSong3.addEventListener(Event.COMPLETE, LoadComplete);
    btnSong3Play.addEventListener(MouseEvent.CLICK, PlaySong);
    btnSong3Stop.addEventListener(MouseEvent.CLICK, Stop);
      Song 4 Definitions
    var Song4:Sound = new Sound();
    pbSong4.addEventListener(Event.COMPLETE, LoadComplete);
    btnSong4Play.addEventListener(MouseEvent.CLICK, PlaySong);
    btnSong4Stop.addEventListener(MouseEvent.CLICK, Stop);
      Song 5 Definitions
    var Song5:Sound = new Sound();
    pbSong5.addEventListener(Event.COMPLETE, LoadComplete);
    btnSong5Play.addEventListener(MouseEvent.CLICK, PlaySong);
    btnSong5Stop.addEventListener(MouseEvent.CLICK, Stop);
      Universal Functions
    function Stop(event:MouseEvent) {
         sndchnlMain.stop();
         ClearNowPlaying();
    function PlaySong(event:MouseEvent) {
         var SongNum:int = Number(event.currentTarget.name.split("btnSong").join("").split("Play").join(""));
         if (this["Song"+SongNum].bytesTotal) {
              if (this["Song"+SongNum].bytesTotal == this["Song"+SongNum].bytesLoaded) {
                   sndchnlMain.stop();
                   ClearNowPlaying();
                   this["NowPlayingSong"+SongNum].visible = true;
                   sndchnlMain = this["Song"+SongNum].play();
         } else {
              this["pbSong"+SongNum].source = this["Song"+SongNum];
              this["pbSong"+SongNum].visible = true;
              this["Song"+SongNum].load(new URLRequest("media/music/Song"+SongNum+".mp3"));
    function LoadComplete(event:Event) {
         var SongNum:int = Number(event.currentTarget.name.split("pbSong").join(""));
         trace("Size of file: " + this["Song"+SongNum].bytesTotal);
         this["Song"+SongNum].close();
         this["Song"+SongNum+"Loaded"] = true;
         if(sndchnlMain) {
              sndchnlMain.stop();
         ClearNowPlaying();
         this["NowPlayingSong"+SongNum].visible = true;
         sndchnlMain = this["Song"+SongNum].play();
         this["pbSong"+SongNum].visible = false;
    function ClearNowPlaying() {
         NowPlayingSong1.visible = false;
         NowPlayingSong2.visible = false;
         NowPlayingSong3.visible = false;
         NowPlayingSong4.visible = false;
         NowPlayingSong5.visible = false;

  • The description for Event ID 0 from source VSTTExecution cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.

    Hi,
    Can any one help me on the below issue ?
    while executing automated test case in test center it is showing as test case is in progress, then i navigated to virtual machine (where the test agent is online), there Internet
    explore has opened automatically and my test case execution started, but with in a seconds IE has closed . However, in test center, test case status is showing as in
    progress, after  2 or 3 min  some of  test cases getting passed and some are failed.
    Here my question is in lab center-->virtual machine, IE has opened automatically and navigated the 2 or 3  links and with in seconds IE has getting closed. Why IE is getting closed without completing execution?
    Error Message :
    The description for Event ID 0 from source VSTTExecution cannot be found. Either the component that raises this event is not installed on your local computer or the
    installation is corrupted. You can install or repair the component on the local computer.
    If the event originated on another computer, the display information had to be saved with the event.
    The following information was included with the event: 
    (mtm.exe, PID 5240, Thread 4) FileAggregatorSessionInfo: Error occurred while deleting temporary directoryException: System.IO.DirectoryNotFoundException: Could not find a part of the path 
       at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
       at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive, Boolean checkHost)
       at Microsoft.VisualStudio.TestTools.Execution.Aggregation.FileAggregator.FileAggregatorSessionInfo.DeleteTemporaryDirectory(String temporaryDirectory)
    the message resource is present but the message is not found in the string/message table
    Thanks
    Suresh
    Suresh

    Hi,
    Can any one help me on the below issue ?
    while executing automated test case in test center it is showing as test case is in progress, then i navigated to virtual machine (where the test agent is online), there Internet
    explore has opened automatically and my test case execution started, but with in a seconds IE has closed . However, in test center, test case status is showing as in
    progress, after  2 or 3 min  some of  test cases getting passed and some are failed.
    Here my question is in lab center-->virtual machine, IE has opened automatically and navigated the 2 or 3  links and with in seconds IE has getting closed. Why IE is getting closed without completing execution?
    Error Message :
    The description for Event ID 0
    from source VSTTExecution cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
    If the event originated on another computer, the display information had to be saved with the event.
    The following information was included with the event: 
    (mtm.exe, PID 5240, Thread 4) FileAggregatorSessionInfo: Error occurred while deleting temporary directoryException: System.IO.DirectoryNotFoundException:
    Could not find a part of the path 
       at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
       at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive, Boolean checkHost)
       at Microsoft.VisualStudio.TestTools.Execution.Aggregation.FileAggregator.FileAggregatorSessionInfo.DeleteTemporaryDirectory(String
    temporaryDirectory)
    the message resource is present but the message is not found in the string/message table
    We are using VS 2013 (premium) and IE 10.0,  scripts have been created on the same versions. It is working fine  on
    developers command prompt but the same tests are getting failed in lab center test agent machine
    test agent log:
    QTAgentService.exe, AgentService: calling AgentObject.RunEndFileCopyComplete
    QTAgentService.exe, AgentProcessManager.WaitForDataCollectionAgentProcessToStart: waiting for agents to start.
    QTAgentService.exe, AgentProcessManager.WaitForDataCollectionAgentProcessToStart: Agents started.
    QTAgentService.exe, AgentProcessManager.PerformActionIgnoringExceptions: Successfully called 'Cleanup' on the test agent
    QTAgentService.exe, AgentProcessManager.PerformActionIgnoringExceptions: Calling 'StopDataCollection(int)' on the data collection agent
    QTAgentService.exe, AgentProcessManager.IsDataCollectionAgentNeeded: IsExecutedOutOfProc? True
    QTAgentService.exe, AgentPro
    QTAgentService.exe, AgentProcessManager.WaitForDataCollectionAgentProcessToStart: Agents started.
    QTAgentService.exe, AgentService: Connection to controller is up.
    Thanks
    Suresh

  • Help me I'm trying to create event listeners

    I am trying to create event listeners
    Whenever any keyboard event occurs the string s gets appended by a,c
    or p.At the end of the program its supposed to print value of s
    But s always happens to null.Please tell me how to correct it....so
    that detection is possible for any case
    import java.io.*;
    import java.awt.event.*;
    public class trial {
    int x;
    public static String s;
    //OutputStream f1=new FileOutputStream("file2.txt");
    public static void keyReleased(KeyEvent e)
    s=s+"a";
    public static void keyPressed(KeyEvent e)
    s=s+"c";
    public static void keyTyped(KeyEvent e)
    s=s+"p";
    public static void main(String args[])
    throws IOException
    char c;
    BufferedReader br =new BufferedReader(new
    InputStreamReader(System.in));
    System.out.println("Entercharactes,'q' to quit.");
    do
    c=(char)br.read();
    System.out.println(c);
    while(c!='q');
    // for(int i=0;i<s.length();++i)
    System.out.println(s);

    I suggest looking at the java tutorial. Your code completely misses the mark and you need to see examples.

  • Which method is used for event creation

    Dear All,
    My client has more then one Purchase Organization. Workflow for Purchase order release very from pur org to pur org. For example - workflow WS92000030 is trigger when PO is created for India pur org where as workflow WS92000021 is trigger when PO is created for US pur org.  
    I checked and found that same Object Type - BUS2012 & event - RELEASESTEPCREATED is used in all Pur. Org PO release workflow. Also I found in Transaction code - SWETYP that Type linkage activate for  BUS2012, RELEASESTEPCREATED in all the PO workflow - WS92000030 & WS92000021.
    As per my knowledge, event can be created in various way such as Function module, Change document, General status management, Business Transaction Events etc.
    Can some one guide me, how can I found that which method is used for event creation in different pur org?
    How can I fould what is the fuctional module used for event creation if Fuctional module used for event creation. 
    For your information, I can see in T. Code - SWUO that 'Result dependent on a check function module'  for all the workflow - WS92000030, WS92000021 etc.
    Thanks in

    Hi Sahu,
    I dont think they have used the Function module or change document or any other kind of methods to trigger the workflow. This is because RELEASESTEPCREATED method is a standard method and it will be triggered by standard SAP. They can not make changes in standard sap saying RELEASESTEPCREATED should be triggered for this Purchase Org .
    Istead what i think is, they might have given the Event Condition for each workflow.
    In SWDD>> basic settings>> Start Events, we can give condition on triggering the workflow.
    Please check this.
    Regards,
    Gautham

  • [JS] Basic question about event listeners and event handlers

    I am very new to the whole topic of event listeners and event handlers.  I'd run the test for the following problem myself, but I don't know where to start, and I just want to know if it's impossible -- that is, if I'm misunderstanding what event listeners and event handlers do.
    Say I have an InDesign document with a text frame that is linked to an InCopy story.  Can I use an "afterImport" event listener on the text frame to perform some action any time the link to the InCopy story gets updated?  And will the event handler have access to both the story that is imported, and the pathname of the InCopy file?
    Thanks.

    Thank you, Kasyan.
    Both of those are good solutions.
    We are currently using InDesign CS4 and InCopy CS5.  I'm hoping to get them to purchase the whole CS5 suite soon, since I'd like to start writing scripts for InDesign CS5 as soon as possible, as long as I'm going to have to be doing it in the not too distant future anyway.  The greater variety of event handlers sounds like it might be something that is crucial to the project I'm working on, so that adds to the argument for getting CS5.
    Thanks again.  You have no idea how helpful this is.  I made some promises to my boss yesterday that I later realized were  based on assumptions of mine about the InDesign/InCopy system that didn't make any sense, and I was going  to have to retract my promises.  But after reading your response I think I can still deliver, in a slightly different way that I had been thinking before.
    Richard

Maybe you are looking for

  • Issue with Adobe PDF IFilter 64 bit

    Hi All, I am facing issue while using Adobe IFilter for 64 bit, the section of code mentioned below is used to load IFilter for PDF IFilter 64 bit using IPersist interface. LibHndl = LoadLibrary(strDLLName.c_str()); if(LibHndl)                  FnPtr

  • File to IDoc scenario( Bypass)-- Error ( Segment is missing) -- urgent pls.

    Hi All, I am doing File to IDoc scenario( Bypass) for Orders05. File is picking succesfully and not posting the idoc in the SAP.. My source file(idoc-xml) consists of all the required data to post the idoc including the segment 'E1EDK01'. but the err

  • My iphone4 round button stops working sometimes. And i need to push it for several times to get a respond. What should I do?

    Why the round button in iphone4 does not operate sometimeS?

  • Question on EDPAR table structure??

    Hi SAP-EDI experts, I have a simple question. My EDI customer number is 100100. This parent EDI customer has number of ship-to codes. Ship-to codes          -         SAP Number GF01                      -         100101   GF02                      -

  • Calculation in Hierarchy

    Hi, I have a DSO, the structure is following, Z_Org, Z_RN,  Z_Value, Z_counter 'Z_Org' & 'Z_RN' are the keys of the DSO. The data in DSO is following, Org1-1      1          300           1 Org1-1      2          300           1 Org1-1      3