Regd Event Listeners and Objects to listen to File events

I have a specific requirement wherein, I want to listen to a java.io.File object pointing to a windows directory and keep track of any sub-files and sub-directories. If any new file or directory is created, I want an event object to be fired and captured by an event listener. Are there any classes already provided in the JDK APIs to meet this requirement.
The situation is pretty much like listening to events fired when emails are received on an Exchange Server using Java Mail API MessageListener and MessageEvent.

You should get in touch with this guy:
http://developer.berlios.de/projects/jfilenotify/
Looks like he might need a little help.

Similar Messages

  • [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

  • All event listeners and models in one file?

    I have one java file for all my event listeners of a programm and one java file for all my models. Is this good?
    I create instances with new AllInOneHandler.MouseHandler() for example.
    Or should I have one file for each event and each model?

    Hi,
    you should have one file for each class or interface - this gives you best control and reusability. Also when you have javadoc-comments in it, big files with many classes in it will become hard to edit.
    When using one file for each class or interface you can import only the needed classes or interfaces instead of importing whole packages - so it is easier to see, what is exactly imported. As so a good structured application has many classes, where each of them is small (and in an own source file), you will have less problems during the evolution of your classes this way.
    If you want to group some classes, why not use sub-packages for this purpose?
    greetings Marsian

  • Problem with Embedded Event Manager and Object Tracking

    Hi,
    I have a 2801 running c2801-advipservicesk9-mz.124-24.T2.bin. It has the following configuration:
    track 300 list boolean or
    object 10
    object 11
    object 12
    object 13
    event manager applet clear_ipsec_tunnel
    event track 300 state down
    action 1.0 cli command "enable"
    action 2.0 cli command "clear crypto session"
    action 3.0 syslog msg "IPSec tunnel has been cleared by clear_ipsec_tunnel applet"
    My problem is that after the tracked object number 300 transitions from an up state to a down state, nothing happens. It seems like the applet doesn't work with object tracking. Here's what I see in logs:
    Dec  7 21:52:32.236 MCK: %TRACKING-5-STATE: 12 ip sla 12 reachability Up->Down
    Dec  7 21:52:37.236 MCK: %TRACKING-5-STATE: 13 ip sla 13 reachability Up->Down
    Dec  7 21:52:57.236 MCK: %TRACKING-5-STATE: 10 ip sla 10 reachability Up->Down
    Dec  7 21:53:07.236 MCK: %TRACKING-5-STATE: 11 ip sla 11 reachability Up->Down
    Dec  7 21:53:07.996 MCK: %TRACKING-5-STATE: 300 list boolean or Up->Down
    That's it. For some reason, the applet won't execute the CLI commands when the EEM applet is triggered. Am I doing something wrong or I have encountered some bug? Thanks.

    jclarke,
    Today I added the router into the tacacs server database and the applet started working just fine by using my login name. So the working configuration looks like this:
    event manager session cli username "my login name"
    event manager applet clear_ipsec_tunnel
    event track 300 state down maxrun 30
    action 1.0 cli command "enable"
    action 2.0 cli command "clear crypto session"
    action 3.0 syslog msg "IPSec tunnel has been cleared by clear_ipsec_tunnel applet"
    Then I tried to use a login name from the local database that has "privelege 15" access and of course the debug output showed me this:
    Dec  8 18:12:58.203 MCK: %TRACKING-5-STATE: 300 list boolean or Up->Down
    Dec  8 18:12:58.203 MCK: fh_track_object_changed: Track notification 300 state down
    Dec  8 18:12:58.203 MCK: fh_fd_track_event_match: track ED pubinfo enqueue rc = 0
    Dec  8 18:12:58.215 MCK: fh_send_track_fd_msg: msg_type=64
    Dec  8 18:12:58.215 MCK: fh_send_track_fd_msg: sval=0
    Dec  8 18:12:58.219 MCK: %HA_EM-6-LOG: clear_ipsec_tunnel : DEBUG(cli_lib) : : CTL : cli_open called.
    Dec  8 18:12:58.227 MCK: %HA_EM-6-LOG: clear_ipsec_tunnel : DEBUG(cli_lib) : : OUT : Router>
    Dec  8 18:12:58.227 MCK: %HA_EM-6-LOG: clear_ipsec_tunnel : DEBUG(cli_lib) : : IN  : Router>enable
    Dec  8 18:12:58.747 MCK: %HA_EM-6-LOG: clear_ipsec_tunnel : DEBUG(cli_lib) : : OUT : Command authorization failed.
    Dec  8 18:12:58.747 MCK: %HA_EM-6-LOG: clear_ipsec_tunnel : DEBUG(cli_lib) : : OUT :
    Dec  8 18:12:58.747 MCK: %HA_EM-6-LOG: clear_ipsec_tunnel : DEBUG(cli_lib) : : OUT : Router>
    Dec  8 18:12:58.747 MCK: %HA_EM-6-LOG: clear_ipsec_tunnel : DEBUG(cli_lib) : : IN  : Router>clear crypto session
    Dec  8 18:12:58.771 MCK: %HA_EM-6-LOG: clear_ipsec_tunnel : DEBUG(cli_lib) : : OUT :                                  ^
    Dec  8 18:12:58.771 MCK: %HA_EM-6-LOG: clear_ipsec_tunnel : DEBUG(cli_lib) : : OUT : % Invalid input detected at '^' marker.
    Dec  8 18:12:58.771 MCK: %HA_EM-6-LOG: clear_ipsec_tunnel : DEBUG(cli_lib) : : OUT :
    Dec  8 18:12:58.771 MCK: %HA_EM-6-LOG: clear_ipsec_tunnel : DEBUG(cli_lib) : : OUT : Router>
    Dec  8 18:12:58.775 MCK: %HA_EM-6-LOG: clear_ipsec_tunnel: IPSec tunnel has been cleared by clear_ipsec_tunnel  applet
    Dec  8 18:12:58.775 MCK: %HA_EM-6-LOG: clear_ipsec_tunnel : DEBUG(cli_lib) : : CTL : cli_close called.
    So I guess this problem arises when you have command authorization enabled and the tacacs server is not reachable or something like that. I have tried to find a way to use the local database instead of using the aaa server but didn't succeed. Although I have found an interesting workaround. Here it is:
    Link: http://blog.ioshints.info/2007/05/command-authorization-fails-with-eem.html
    Workaround found after reading the "Executing IOS commands from Tcl shell" from the "Tclsh on Cisco IOS tutorial".
    On the above article it is mentionned that the ios_config command is executed inside the context of another VTY line (also found with the AAA debug). The workaround is to define the FIRST VTY line with "transport input none" to prevent ssh or telnet to grab it and to configure the aaa authorization without any command authorization for this line.
    Kind regards
    Christian Chautems
    Looks great, but I am not quite sure how to "configure the aaa authorization without any command authorization for this line".
    Anyway, jclarke thank you so much for taking your time to look into my problem and for your help.

  • Asynchronous Event listeners and security

    Hi,
    I have written an asynchronous event listener that would record a users "login time" when the user logs into my portal. I record this login time as a property value in a custom user property set.
    Unfortunately, the thread that executes the logic in the listener, does not have the rights to modify the property set data, as you can see from the following trace :
    com.xyz.user.UserException: Unable to set user property
    at com.nokia.npp.user.impl.UserImpl.setProperty(UserImpl.java:113)
    at com.xyz.postlogin.TrackPostLoginTask.handleEvent(TrackPostLoginTask.java:95)
    at com.bea.p13n.events.internal.AsynchronousEventHandler$EventRequest.execute(AsynchronousEventHandler.java:145)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
    Caused by: java.rmi.RemoteException: EJB Exception: ; nested exception is:
    java.lang.SecurityException: User <WLS Kernel> does not have permission to modify data for joesmith. Users can only be modified by themselves, or by a member of the role [Admin, PortalSystemAdministrator].
    at weblogic.ejb20.internal.EJBRuntimeUtils.throwRemoteException(EJBRuntimeUtils.java:102)
    at weblogic.ejb20.internal.BaseEJBHome.handleSystemException(BaseEJBHome.java:307)
    at weblogic.ejb20.internal.BaseEJBObject.postInvoke(BaseEJBObject.java:263)
    at weblogic.ejb20.internal.StatelessEJBObject.postInvoke(StatelessEJBObject.java:140)
    at com.bea.p13n.usermgmt.profile.internal.UserProfileManager_mfa736_EOImpl.setProperty(UserProfileManager_mfa736
    _EOImpl.java:215)
    at com.bea.p13n.usermgmt.profile.internal.ProfileWrapperImpl.setProperty(ProfileWrapperImpl.java:231)
    at com.nokia.npp.user.impl.UserImpl.setProperty(UserImpl.java:109)
    ... 4 more
    Caused by: java.lang.SecurityException: User <WLS Kernel> does not have permission to modify data for dnataraj. Users ca
    n only be modified by themselves, or by a member of the role [Admin, PortalSystemAdministrator].
    at com.bea.p13n.usermgmt.profile.internal.UserProfileManagerImpl.authorizeModification(UserProfileManagerImpl.ja
    va:133)
    at com.bea.p13n.usermgmt.profile.internal.ProfileManagerImpl.setProperty(ProfileManagerImpl.java:525)
    at com.bea.p13n.usermgmt.profile.internal.UserProfileManager_mfa736_EOImpl.setProperty(UserProfileManager_mfa736
    _EOImpl.java:205)
    this comes across as a bit odd to me. Does anyone have any advice/ideas?
    cheers!
    BR,
    deepak

    take a look at runAs()
    http://edocs.beasys.com/wlp/docs81/javadoc/com/bea/p13n/security/Authentication.html
    Chris Jolley
    Portal Architect

  • 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.

  • Regd FIle Event Generator

    Hi,
    Am having a file event generator,and the presence one such file[string type] in the folder would trigger one of my JPD's. Now, I want to read the contents of the file as well, in addition to the complete file name..I guess this can be done by reading the meta data, but am having problems doing this..
    How do I read this metadata,to know the full file name the the file contents?
    Any help would be appreciated.
    Thanks In Advance,
    RB

    Hi,
    I did like this
    1. Created a channel where an set the qualifiedMetadataType="eg:FileEventGenerator"
    Ex.
    <channels xmlns="http://www.bea.com/wli/broker/channelfile"
              channelPrefix="/Bilprovningen"
    xmlns:eg="http://www.bea.com/wli/eventGenerator"
    xmlns:dp="http://www.bea.com/wli/control/dynamicProperties">
    <channel name ="FileHandling" messageType="none">
    <channel name ="MegadiscInvoiceFileChannel" messageType="xml" qualifiedMessageType="utskrift" qualifiedMetadataType="eg:FileEventGenerator"/>
    </channel>
    </channels>
    2. Create a process with a subscriptin like thist
    * @jpd:mb-static-subscription message-metadata="{x1}" channel-name="/Bilprovningen/FileHandling/MegadiscInvoiceFileChannel" message-body="{x0}"
    public void subscription(com.bea.xml.XmlObject x0, com.bea.wli.eventGenerator.FileEventGeneratorDocument x1) throws Exception
    //#START: CODE GENERATED - PROTECTED SECTION - you can safely add code above this comment in this method. #//
    // input transform
    // parameter assignment
    this.invoiceDocument = (noNamespace.UtskriftDocument) x0;
    this.fileEventGeneratorDocument = x1;
    //#END : CODE GENERATED - PROTECTED SECTION - you can safely add code below this comment in this method. #//
    3. You could then access the x1 I think to read the meta data.
    Regards
    /Johan

  • Public Folder Free/Busy event 4003 and 4004

    Hello,
    We migrated from exchange 2003 to 2010. Migration was successfull; all mailboxes are moved, public folder replicated and exchange 2003 was uninstalled like it should.  Public Folder Hierarchy was moved to the new administrative group.
    Since the last exchange 2003 server was uninstalled, we get events 4003 and 4003 on our CAS servers.
    event id 4004
    Process Microsoft.Exchange.InfoWorker.Common.Delayed`1[System.String]: Unable to find a public folder server for organizational unit (OU) EXCHANGE ADMINISTRATIVE GROUP (FYDIBOHF23SPDLT).
    The service will attempt to find a random server, which may take a longer time to service the request.
    event id 4003
    Process Microsoft.Exchange.InfoWorker.Common.Delayed`1[System.String]: DAVPublicFolderRequest for 1 mailboxes at EXCHANGE ADMINISTRATIVE GROUP (FYDIBOHF23SPDLT) failed.
    The exception returned is Microsoft.Exchange.InfoWorker.Common.Availability.PublicFolderRequestProcessingException: The public folder server for the given legacy mailbox was not found.. The request information is
    <Null>.
    . Name of the server where exception originated: CAS1. The Availability service could not successfully retrieve Schedule+ free/busy data for one or more legacy Exchange mailboxes.
    To find the root cause of this error, increase the diagnostic logging level of the MSExchange Availability service
    I have set the log level to expert, but no additional usefull information showed up.  I can't find any legacy mailbox on the exchange 2010 servers.
    I didn't receive any complaints about availability information so far. (all clients on OL2010)
    Anyone an idea on how to solve this issue?
    Thanx

    http://social.technet.microsoft.com/Forums/exchange/en-US/3203b390-d52a-4e81-8a7e-c2266d909589/exchange-2010-cannot-see-freebusy-for-exchange-2003-mailboxes?forum=exchange2010

  • How to create custom attributes & object classes through ldif files in OID

    Hi,
    I have to create 4 attributes and one object class(custom) in OID. I want to creae these attributes and object class through LDIF file.
    I tried creating an attribute through this command
    ldapadd -p 389 -h localhost -D cn=orcladmin -w password -f D:/newattr.ldif
    this ldif file contains inf. for creating a new attributes:
    dn: cn=subschemasubentry
    changetype: add
    add: attributetypes
    attributetypes: ( 1.2.3.4.5.6.10 NAME "xsUserType_new" DESC "User Type Definition" EQUALITY caseIgnoreMatch
    SYNTAX "1.3.6.1.4.1.1466.115.121.1.15" )
    I am getting error: Object class violation
    Failed to find add in mandatory or optional attribute list.
    Please help to find where I am going wrong...
    Thanks.

    Hi Ajay,
    Thank you for the help. Now i am able to create both attributes and object classes in OID through Ldif files.
    I was getting constraint violation error because (I think) I was not giving proper naming convection for attributes and object classes. For OID, there are certain Ldap naming conventions. They are as follows:
    # X below is the enterprise number assigned by IANA
    1.3.6.1.4.1.X.1 - assign to SNMP objects
    1.3.6.1.4.1.X.2 - assign to LDAP objects
    1.3.6.1.4.1.X.2.1 - assign to LDAP syntaxes
    1.3.6.1.4.1.X.2.2 - assign to LDAP matchingrules
    1.3.6.1.4.1.X.2.3 - assign to LDAP attributes
    1.3.6.1.4.1.X.2.4 - assign to LDAP objectclasses
    1.3.6.1.4.1.X.2.5 - assign to LDAP supported features
    1.3.6.1.4.1.X.2.9 - assign to LDAP protocol mechanisms
    1.3.6.1.4.1.X.2.10 - assign to LDAP controls
    1.3.6.1.4.1.X.2.11 - assign to LDAP extended operations
    By using these conventions for attributes and object class, I did got any error and they were created in OID.
    Thanks a zillion.
    Kalpana.

  • Listen for an events for Swing objects in a separate class?

    Hi all, sorry if this is in the wrong section of the forum but since this is a problem I am having with a Swing based project I thought i'd come here for help. Essentially i have nested panels in separate classes for the sake of clarity and to follow the ideas of OO based development. I have JPanels that have buttons and other components that will trigger events. I wish for these events to effect other panels, in the Hierachy of my program:
    MainFrame(MainPanel(LeftPanel, RightPanel, CanvasPanel))
    Sorry I couldnt indent to show the hierarchy. Here LeftPanel, RightPanel and CanvasPanel are objects that are created in the MainPanel. For example i want an event to trigger a method in another class e.g. LeftPanel has a button that will call a method in CanvasPanel. I have tried creating an EventListner in the MainPanel that would determine the source and then send off a method to the relevant class, but the only listeners that respond are the ones relevant to the components of class. Can I have events that will be listened to over the complete scope of the program? or is there another way to have a component that can call a method in the class that as an object, it has been created in.
    Just as an example LeftPanel has a component to select the paint tool (its a simple drawing program) that will change a color attribute in the CanvasPanel object. Of course I realize i could have one massive Class with everything declared in it, but I'd rather learn if it is possible to do it this way!
    Thanks in advance for any help you can offer
    Lawrence
    Edited by: insertjokehere on Apr 15, 2008 12:24 PM

    Thanks for the response, ive added ActionListneres in the class where the component is, and in an external class. The Listeners work inside the class, but not in the external class
    import java.awt.event.ActionEvent;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.ActionListener;
    public class LeftPanel extends JPanel implements ActionListener {  
        /* Constructing JButtons, null until usage of the constructor */
        JButton pencilBut;
        JButton eraserBut;
        JButton textBut;
        JButton copyBut;
        JButton ssincBut;
        JButton ssdecBut;
        ActionListener a = new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                System.out.print("\nNot supported yet.");
        /* The Top Panel contains the title of program */
        public LeftPanel(Dimension d){
            /* Sets up the layout for the Panel */
            BoxLayout blo = new BoxLayout(this,BoxLayout.Y_AXIS);
            this.setLayout(blo);
            /* Sets Up the Appearance of the Panel */
            this.setMinimumSize(d);
            this.setBackground(Color.RED);
            this.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
            /* Pencil Tool */
            pencilBut = new JButton("Pencil");
            pencilBut.setAlignmentX(Component.CENTER_ALIGNMENT);
            pencilBut.setActionCommand("pencil");
            pencilBut.addActionListener(a);
            this.add(pencilBut);
            /* Eraser Tool */
            eraserBut = new JButton("Eraser");
            eraserBut.setAlignmentX(Component.CENTER_ALIGNMENT);
            eraserBut.addActionListener(a);
            this.add(eraserBut);
            /* Text Tool */
            textBut = new JButton("Text");
            textBut.setAlignmentX(Component.CENTER_ALIGNMENT);
            textBut.addActionListener(a);
            this.add(textBut);
            /* Copy Previous Page */
            copyBut = new JButton("Copy Page");
            copyBut.setAlignmentX(Component.CENTER_ALIGNMENT);
            copyBut.addActionListener(a);
            this.add(copyBut);
            /* Stroke Size Increase */
            ssincBut = new JButton("Inc");
            ssincBut.setAlignmentX(Component.CENTER_ALIGNMENT);
            ssincBut.addActionListener(a);
            this.add(ssincBut);
            /* Stroke Size Decrease */
            ssdecBut = new JButton("Dec");
            ssdecBut.setAlignmentX(Component.CENTER_ALIGNMENT);
            ssdecBut.addActionListener(a);
            this.add(ssdecBut);
            System.out.print("\nLeftPanel Completed");
        public void actionPerformed(ActionEvent e) {
            System.out.print("\nAction Performed");
        }But this is not picked up in my external class here
    import java.awt.event.ActionEvent;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.ActionListener;
    public class MainPanel extends JPanel implements ActionListener {
        /* Creates a new the main JPanel that is used in the FlipBookFrame to contain all of the elements */
        public MainPanel(){
            /* TopPanel constraints*/
            tpcs.gridx = 1;
            tpcs.gridy = 0;
            tpcs.gridwidth = 1;
            tpcs.gridheight = 1;
            tpcs.fill = GridBagConstraints.BOTH;
            tpcs.weightx = 0.0;
            tpcs.weighty = 1.0;
            /* LeftPanel Constraints*/
            lpcs.gridx = 0;
            lpcs.gridy = 0;
            lpcs.gridwidth = 1;
            lpcs.gridheight = 3;
            lpcs.fill = GridBagConstraints.BOTH;
            lpcs.weightx = 1.0;
            lpcs.weighty = 1.0;
            /* CentrePanel Constraints*/
            cpcs.gridx = 1;
            cpcs.gridy = 1;
            cpcs.gridwidth = 1;
            cpcs.gridheight = 1;
            cpcs.fill = GridBagConstraints.NONE;
            cpcs.weightx = 0.0;
            cpcs.weighty = 0.0;
            /* RightPanel Constraints*/
            rpcs.gridx = 2;
            rpcs.gridy = 0;
            rpcs.gridwidth = 1;
            rpcs.gridheight = 3;
            rpcs.fill = GridBagConstraints.BOTH;
            rpcs.weightx = 1.0;
            rpcs.weighty = 1.0;
            /* BottomPanel Constraints*/
            bpcs.gridx = 1;
            bpcs.gridy = 2;
            bpcs.gridwidth = 1;
            bpcs.gridheight = 1;
            bpcs.fill = GridBagConstraints.BOTH;
            bpcs.weightx = 0.0;
            bpcs.weighty = 1.0;   
            this.setLayout(gblo);   //Sets the Layout of the panel to a GridBagLayout
            this.add(tp, tpcs); //Adds the TopPanel to the MainPanel using the TopPanel layout
            this.add(lp, lpcs); //Adds the LeftPanel to the MainPanel using the LeftPanel layout
            this.add(cp, cpcs); //Adds the CanvasPanel to the MainPanel using the CanvasPanel layout
            this.add(rp, rpcs); //Adds the RightPanel to the MainPanel using the RightPanel layout
            this.add(bp, bpcs); //Adds the BottomPanel to the MainPanel using the BottomPanel layout
            gblo.layoutContainer(this); //Lays Out the Container
        public PanelSizes getPanelSizes(){
            return ps;
        public void actionPerformed(ActionEvent e) {
            System.out.print("\nExternal Class finds event!");
            /*String command = e.getActionCommand();
            if (command.equals("pencil")){
                System.out.print("\nYESSSSSSSSSSSSSSSSSSSSS!");
        /* Create of objects using the PanelSizes funtions for defining the */
        PanelSizes ps = new PanelSizes();   //Creates a new PanelSizes object for sizing the panel
        CanvasPanel cp = new CanvasPanel(ps.getCentrePanelDimension()); //Creates a new Canvas Panel
        TopPanel tp = new TopPanel(ps.getHorizontalPanelDimension()); //Creates the TopPanel
        BottomPanel bp = new BottomPanel(ps.getHorizontalPanelDimension()); //Creates the BottomPanel
        LeftPanel lp = new LeftPanel(ps.getVerticalPanelDimension()); //Creates the LeftPanel
        RightPanel rp = new RightPanel(ps.getVerticalPanelDimension());   //Creates the RightPanel
        /* I have chosen to create individual constraints for each panel to allow for adding of all
         components a the end of the constructor. This will use slightly more memory but gives clarity
         in the code */
        GridBagConstraints cpcs = new GridBagConstraints();
        GridBagConstraints tpcs = new GridBagConstraints();
        GridBagConstraints bpcs = new GridBagConstraints();
        GridBagConstraints lpcs = new GridBagConstraints();   
        GridBagConstraints rpcs = new GridBagConstraints();
        GridBagLayout gblo = new GridBagLayout();
    }Any help will be greatly appreciated :-)

  • Listening for an event outside of the object...

    Hey, I spent a lot of my day trying to figure out how to
    listen for an event outside of an instantiated object of my own.
    I made my own class called
    Link. When my Link class is instantiated, a Loader object
    (var loader:Loader) is added and it loads a user-specified external
    PNG file. I want to track the Event.COMPLETE event OUTSIDE of my
    Link class, like in my FLA's Actionscript.
    So, I tried a few things without any luck, and by these you
    might get the idea of exactly what I'm trying to do:
    var link1:Link = new Link(...);
    link1.loader.addEventListener(Event.COMPLETE, handler);
    That didn't work, so I tried:
    var link1.Link = new Link(...);
    var loader = link1.getChildByName("loader") as Loader;
    loader.addEventListener(Event.COMPLETE, handler);
    ... that didn't work either. :(
    Any ideas?
    If I am taking the completely wrong approach please do let me
    know. If there's ANY way to know WHEN my loader has completed
    loading its image outside of my Link class...
    Thanks!
    ~ Andrew Merskin

    Let your Link class handle the Loader events. When
    Event.COMPLETE fires,
    just redispatch the event or dispatch a custom event.
    Example 1:
    link1.addEventListener("ALLDONELOADING", linkEventHandler);
    function linkEventHandler(event:Event)
    if(event.type == "ALLDONELOADING")
    // do something or nothing at all
    // Inside your link class you are listening for the load
    complete
    function loadCompleteHandler(event:Event)
    dispatchEvent(new Event("ALLDONELOADING")));
    Example 2:
    link1.addEventListener(Event.COMPLETE, linkEventHandler);
    function linkEventHandler(event:Event)
    if(event.type == Event.COMPLETE)
    // do something or nothing at all
    // Inside your link class you are listening for the load
    complete
    function loadCompleteHandler(event:Event)
    dispatchEvent(event);

  • How to create many objects listening for one event

    I'm experimenting with the EventDispatcher class and I have a
    test class working. I want to use a loop to create a variety of
    movie clips that all listen for an event that gets dispatched every
    half a second. I have the event dispatching properly. My problem is
    that when creating the objects, the temporary variable I use to
    hold each created object has a life that extends beyond the loop in
    which it is instantiated. Rather than all five created objects
    changing color, only the last one changes color (see the code
    below--it lives on the first frame of an FLA file).
    This is not entirely surprising when I look at the code --
    'this' refers to the global scope and 'square' refers to the last
    created object that it pointed to. Here's the resulting trace:
    handler runing, square name is square 4
    this class name is global
    handler runing, square name is square 4
    this class name is global
    handler runing, square name is square 4
    this class name is global
    handler runing, square name is square 4
    this class name is global
    handler runing, square name is square 4
    this class name is global
    How can I modify this code so that each square object changes
    its own color?

    graphics.clear in the context of that function handler in my
    code would refer not to the squares but to the global scope,
    wouldn't it? In which case you'd be clearing all the graphics from
    your top level movie. I tried changing 'square.graphics' to just
    'graphics' in my handler and my squares just remained the original
    steady black.
    Your code doesn't use a loop and therefore isn't re-using a
    variable. You've escaped my 'logical errors' through brute force.
    (BTW, I think my code would work in AS2 if I used the old-school
    draw methods). Suppose you had to create 100 objects? Would you
    want to manually instantiate each one, typing that function over
    and over again? You'd have 500 lines of highly redundant code!
    Maybe try your example using a loop instead? I think you'll
    find it's pretty tough to sneak any vars like 'i' or 'square' from
    the global scope into the handler--the handler refers to the
    living, breathing variable rather than it's value at the time the
    handler was instantiated. Furthermore, you can't sneak any
    information about the square into your handler via the event object
    because the event object is created in a totally different place.

  • Which object in hierarchy should add event listener?

    Hello all,
    I'm quite new to the whole OOP thing, and one of the things I keep wondering about is this:
    Which class should listen for events if the choice is between a contained class or a containing class?
    For example:
    An instance of Game holds an instance of Board which holds an array of instances of fields.
    This might be a scenario for a simple board game, I guess (In my case I am working on Reversi).
    A player should click a field to place a piece on it. I could let the Field class listen for the click event,
    but when a player places a piece, other pieces might have to flip, so an object at a higher level should handle this (board / game / maybe another object).
    So in order to make sure this happens, I could let the field object listen for the event and than tell the higher-level-object to do his thing, or I could
    let the higher-level-object add an event listener on the field object, and than both flip the nescesary pieces as well as tell the field to add a piece on itself.
    Could anyone explain which and why either solution (or maybe a third on) is better?
    Thanks for your time!

    qdudu wrote:
    Hello all,
    I'm quite new to the whole OOP thing, and one of the things I keep wondering about is this:
    Which class should listen for events if the choice is between a contained class or a containing class?The class that can respond to the events should implement the Listener.
    For example:
    An instance of Game holds an instance of Board which holds an array of instances of fields.
    This might be a scenario for a simple board game, I guess (In my case I am working on Reversi).
    A player should click a field to place a piece on it. I could let the Field class listen for the click event,
    but when a player places a piece, other pieces might have to flip, so an object at a higher level should handle this (board / game / maybe another object).Sounds like Board would be a good choice, then.
    So in order to make sure this happens, I could let the field object listen for the event and than tell the higher-level-object to do his thing, or I could
    let the higher-level-object add an event listener on the field object, and than both flip the nescesary pieces as well as tell the field to add a piece on itself.Sounds like the field object can't do much except forward the event to the real handler. In that case I'd vote for the higher-level-object as the listener.
    Could anyone explain which and why either solution (or maybe a third on) is better?In this case it could be either one. Try both and see. But based on the little you've posted here I'd vote for the higher-level-object, the Board.
    %

  • Does removeChild remove the object's event listeners?

    Hi
    If you dynamically create a parent movieclip, and dynamically add a color picker to each clip, and add an event listener for each color picker, does a removeChild on the parent movieClip remove event listeners belonging to any of it's children?
    Thanks
    Shaun

    Ahh - thanks Ned
    Is there any software you could recommend that monitors and shows you what or how many event listeners are open, memory consumption etc, to help you to trim the fat from your coding?
    Thanks
    Shaun

  • Why and how to use events in abap objects

    Dear all,
      Please explain me why and how to use events in abap objects with real time example
    regards
    pankaj giri

    Hi Pankaj,
    I will try to explain why to use events... How to use is a different topic.. which others have already answered...
    This is same from your prev. post...
    Events :
    Technically speaking :
    " Events are notifications an object receives from, or transmits to, other objects or applications. Events allow objects to perform actions whenever a specific occurrence takes place. Microsoft Windows is an event-driven operating system, events can come from other objects, applications, or user input such as mouse clicks or key presses. "
    Lets say you have an ALV - An editable one ...
    Lats say - Once you press some button  you want some kind of validation to be done.
    How to do this ?
    Raise an Event - Which is handled by a method and write the validation code.
    Now you might argue, that I can do it in this way : Capture the function code - and call the validate method.
    Yes, in this case it can be done.. But lets say .. you change a field in the ALV and you want the validation to be done as soon as he is done with typing.
    Where is the function code here ? No function code... But there is an event here - The data changed event.
    So you can raise a data changed event that can be handled and will do the validation.
    It is not user friendly that you ask the user to press a button (to get the function code) for validation each time he enters a data.
    The events can be raised by a system, or by a program also. So in this case the data changed event is raised by a system that you can handle.
    Also, Lets say on a particular action you want some code to trigger. (You can take the same example of validation code). In this case the code to trigger is in a separate class. The object of which is not available here at this moment. (This case happens very frequently).
    Advantage with events : Event handlers can be in a separate class also.
    e.g : In the middle of some business logic .. you encounter a error. You want to send this information to the UI (to user - in form of a pop up) and then continue with some processing.
    In many cases - A direct method call to trigger the pop up is not done. Because (in ideal cases) the engine must not interact with UI directly - Because the UI could be some other application - like a windows UI but the error comes from some SAP program.
    So - A event is raised from the engine that is handled in the UI and a pop up is triggered.
    Here -- I would have different classes (lets say for different Operating Systems). And all these classes must register to the event ERROR raised in application.
    And these different classes for different Operation systems will have different code to raise a pop-up.
    Now you can imagine : If you coded a pop-up for Windows (in your application logic) .. it will not work for Mac or Linux. But of you raise a event.. that is handled separately by a different UI classes for Win, Linux or Mac  they will catch this event and process accordingly.
    May be I complicated this explanation .... but I couldn't think of a simpler and concrete example.
    Cheers.
    Varun.

Maybe you are looking for