How to trap WindowClose event?

I would like to trap the WindowClose event such that when my closing condition is not satisfied, the window would not close.
Right now everytime i click the X button at the upper right of the window, the window closes automatically. I would like to know how to trap that event so I can control the closing of the window.
tnx!

For that you have to implement java.awt.event.WindowListener and override the windowClosing or windowClosed method according to your requirement. Put your code inside that method. But before doing that you have to set the default close operation.
setDefaultCloseOperation(0);
Hope this would work.
Anirban

Similar Messages

  • How to trap the event before unlock of locked text frames

    How to trap the event before the message "You must check out the contents of this frame in order to make changes. Check out now?" for locked text frames?
    I have tried installing the service Responder kUserEditTextCmdResponder
    The responder event is fired after the unlock of text frame in this case.
    I was trying the service kEditCmdPreProcessService, but I could not find the companion interface for this service.
    How to find the companion interface?

    calle111 wrote:
    The answer to why i need the event executed if nothing has changed is that in my application the text ring will hold some predefined settings for some other controls. If the user selects one of the predefined settings from the text ring a bunch of other controls will take predefined values. These values in the other controls can now be altered by the user. If the user now wants to re-apply the same set of pre-defined settings as last time it should be as simple as selecting the pre-defined settings from the text ring. If now the same value is selected from the text ring, no event will be executed.
    What you should do instead is change the value of the ring to a "special" value (e.g. using a local variable) whenever one of the other settings change, indicating that the settings have been modified. It seems wrong to show an inconsistent value in the ring, right?
    Now, whenever you change it back to one of the default settings, is IS a value changed event and there is no problem. .
    Here's a quick draft.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    event_testerMOD.vi ‏10 KB

  • How to trap custom events

    Hello
    I am writing an addin for GroupWise Where I need to trap the event that
    the user drags&drops a message(or whatever) from one folder to another. Does
    this have to be done via a TPH dll, or can it be done completely via a C3PO?
    (I realize this is a bit of a cross-post, but noone seems to be 'home' in
    the c3po forum)
    Thanks Muchly..
    Andrew

    Chris
    Thank you for your reply. The only way I have been able to detect this
    event is via a very convoluted method.
    What I do is maintain a list of message ID's in a C3P0. On a timer, I scan
    the messages to see if the message counts change. If so, I query my list to
    find the new message and bounce that message ID back to my logic. The only
    downside to this approach is performance and the occaisional misfire on
    account of GW not liking to give up control very easily.
    To help performance, I store the messageID's in a balanced binary tree. It
    was the most efficient way I could think to do it.
    Methinks this must be a bug in GW..... or there is some switch that must be
    thrown to get the TPH to see those tokens.
    Hope that Helps,
    Andrew
    <chr_white@yaNO_SPAMhoo.com> wrote in message
    news:[email protected]...
    >> Shane
    >>
    >> Thanks for your reply. What I tried to do is create a custom message
    >> and
    >> insert the registry key to hopefully 'tune in' to that event. The
    >> documentation says that you can get custom messages by inserting keys
    >> saying
    >> for example GW#E#365 which will give you all commands with that
    >> persistentID. However, in trying it, I did not get any response from
    >> GroupWise for that event. I just REALLY dont want to have to make a TPH
    >> dll
    >> if I dont have to.
    >>
    >> Andrew
    >>
    >> <Shane>; "Devnet SysOp 57" <[email protected]> wrote in message
    >> news:[email protected]...
    >> > Hello, Andrew.
    >> >
    >> > I did a quick scan of the C3PO documentation and couldn't find anything
    >> > that looked like it dealt with the moving of a message. I did notice
    >> > that in the token documentation there is a token called ItemFolderLink
    >> > and another called ItemFolderAltMove. I'm not sure if these would be
    >> > the exact tokens that get generated (or even if any do..) when a
    >> > message
    >> > is moved but it looks like a place you might want to start
    >> > experimenting
    >> > with.
    >> >
    >> > Regards,
    >> >
    >> > Shane
    >> >
    >> > In article <[email protected]>,
    >> > [email protected] says...
    >> >> Hello
    >> >>
    >> >> I am writing an addin for GroupWise Where I need to trap the event
    >> >> that
    >> >> the user drags&drops a message(or whatever) from one folder to
    >> >> another.
    >> >> Does
    >> >> this have to be done via a TPH dll, or can it be done completely via a
    >> >> C3PO?
    >> >> (I realize this is a bit of a cross-post, but noone seems to be 'home'
    >> >> in
    >> >> the c3po forum)
    >> >>
    >> >> Thanks Muchly..
    >> >>
    >> >> Andrew
    >> >>
    >> >>
    >> >>
    >>
    >>
    >
    > Andrew,
    >
    > Did you discover a means by which to capture these events at all?
    >
    > I have a TPH DLL running (for other reasons as well) and I'm also trying
    > to
    > capture these events. Unfortunately, these events do not appear to
    > generate
    > tokens at all, so even going the TPH route is not going to work for you
    > (unless I'm really missing something).
    >
    > Chris

  • How to trap navigation event?

    Anyone can help? I need to trap the navigation events, such as First, Last, Next and Previous? Does SBO have these event?

    Hi,
    In the UI API help file you have the complete list of the menu ID. The topic is "List of Menu Item IDs".
    You can also get the menuUID from SBO. Go to the systray and double click on the SBO icon. This will show a window. Whenever you make a click on SBO, the values on the window will be updated with the information about the clicked item.
    Regards,
    Ibai Peñ

  • How to trap applet window closing event?

    Hi all,
    I would like to know how could one trap the event of the browser window containing an applet being closed by the user?
    Thank you,

    Hi. this would be useful to me too.
    Trouble is, I'm not sure that you can. applet.stop( )
    and applet.destroy( ) might be called, but there is
    no guarentee that you can complete processing before
    you are terminated, especially if you need to do
    something slow, like returning state data to your
    server. And you can't stop the broswer closing.
    I know that in Javascript, you can catch and even
    stop the browser window being closed, which is how
    things like goggledocs can ask for confirmation
    before closing. (window.onbeforeunload( ) ).
    I have toyed with the idea of having a
    javascript/ajax thread in my html, to catch this
    termination, and communicate back to the server from
    java to say a document has changed, but it all seems
    rather heavyweight for such a simple task.Look at Runtime.addShutdownHook()
    You could also try using a WindowListener as well and trap the WindowClose Event.
    stop() should do very little other than invalidate the current thread/run flags
    and then exit. ie: a stop() example
    public void stop()
    task = null;
    or
    public void stop()
    running = false;
    Your run method should look for a stop condition and then exit.
    Otherwise you could be doing stop processing while run is still
    running.
    (T)

  • How can i trap javafx events?

    Hello,
    Has anyone tried to trap events in a javafx application by extending java.awt.EventQueue? I tired to do that by overriding dispatchEvent and push Eventqueue to SystemEventQueue. But the dispatchEvent is not trapping any events. Any thoughts?
    The reason I want to do this is to implement a modal dialog in javafx. There does not seem to be a class as of now for implementing Dialog.
    Regards
    Draz

    Look at http://code.google.com/p/jfxtras/
    I think they have a modal dialog.

  • Stopping WindowClosing Event

    HI, I have a question about stopping WindowClosing Event from continuing to WindowClosed Event.
    I have a JFrame implementing WindowListener - and I'd like to stop frame from closing by intercepting WindowClosing Event (so it never reaches WindowClosed Event).
    Is there anyone who know how to do it?
    Thank you in advance.

    Once you set the default close operation as follows:
    setDefaultCloseOperation( DO_NOTHING_ON_CLOSE );
    You must explicitly close the window yourself. Something like:
    addWindowListener( new WindowAdapter()
         public void windowClosing(WindowEvent e)
              String message = "Do you want to close the window?";
              int result = JOptionPane.showConfirmDialog(parent, message, "Close Window", JOptionPane.YES_NO_OPTION);
              if (result == JOptionPane.YES_OPTION)
                   window.dispose();
    });

  • How to trap the first key?

    Hello World,
    I am using JTable in that I am using custom TextField as a Editor Component. Now I want to trap the first key pressed in the textfield.
    I am using public boolean editCellAt(int row,int column,EventObject e) method. In this method I get the value of �e� as a null if I press any key. So I can not trap the event here.
    The next try is to putting KeyListener in textfield class, this is also not working because it gets called after EditCellAt method.
    I tried to override the processKeyBinding() method but this seems to trap all the key pressed and not allow me to navigate also.
    Can anybody provide me the solution how I can trap the first key only.
    Thanks in advance,
    Sachin Dare.

    Hello World,
    I am using JTable in that I am using custom TextField
    as a Editor Component. Now I want to trap the first
    key pressed in the textfield.what do you want it for?
    [.. usual l aproaches snipped ]
    The reason this is not working is that JTable uses a very uncommon way to route this first keyEvent: it comes via Jtable.processKeyBindings which first tries to start the edit with it (buggily "forgetting" to pass the keyEvent along...) and if this started the edit it will pass both keyStroke and keyEvent to the editorComponent's processKeyBindings. At his time the editorComponent is part of the container hierarchy.
    So a possible solution (did not try it, though) might be to have a ComponentListener on the editorComponent, set a flag when being added to the table and reset the flag when receiving the first KeyStroke in proocessKeyBinding after the componentEvent. Alternatively, you might try to set/reset the flag as a clientProperty in table.processKeyBindings.
    Greetings
    Jeanette

  • How to trap ALT key?

    Hello guys!
    After searching and investigating quite a lot, I am posting
    my problem here in hope that God bless me with success
    I am working on an eLearning course whereas client requied
    the course to be keyboard accessible. He wants all the shortcuts
    with Alt key combination.
    I can trap the Alt key with the use of enterframe but that
    makes my course processing heavy so I tried to trap Alt key with
    keylistener event but unfortunately keylistener event doesn't
    listen Alt key
    Could anyone suggest me how to trap Alt key without using
    enterframe or interval?
    Thanks a lot for sparing your precisious time.

    I believe Alt-Space is a keyboard shortcut in Windows XP to bring up the window menu for any app...so it's not just a LabVIEW thing. Further, it appears that Windows grabs that key combination before a LabVIEW event structure can get it.  I don't know any way around this behavior, since Windows appears to be taking matters into its own hands with certain key combinations.  My advice would be to use a different key combination for your app.
    -D
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

  • How to trap ALT-Space key combo. ?

    Hi,
          Does anyone know how to trap Alt-space?  The user is probing a PC board and may want to keep their eyes on the work.  The space-bar makes a nice big "next" button, and the Alts on either side seem a natural choice for "back".  But, when I try to trap the Alt-key/space keyboard-event, the program nevers sees it.  Instead, a file dialog is displayed, as if Alt is trapped by the VI-menu-bar - which isn't even displayed!
    Cheers.
    When they give imbeciles handicap-parking, I won't have so far to walk!

    I believe Alt-Space is a keyboard shortcut in Windows XP to bring up the window menu for any app...so it's not just a LabVIEW thing. Further, it appears that Windows grabs that key combination before a LabVIEW event structure can get it.  I don't know any way around this behavior, since Windows appears to be taking matters into its own hands with certain key combinations.  My advice would be to use a different key combination for your app.
    -D
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

  • How to trap action of Back Button in IE Toolbar

    Hi
    Plz tell me a way How to trap action of Back Button in IE Toolbar

    hi i found something but it can get real messy.
    By the way, I think it can be hooked, but not trap, as in like cancel it if we like
    Manu G, Colin Fraser, Daniel Amsler - i think it's from these guys, i dunno if its ok to paste the link here so ill just paste the exact text
    =======================================================
    Sure, why not!
    Use the onunload event of the body tag.
    Something like this:
    <body OnUnload="alert('Woo hoo..');">
    This will be called everytime the backbutton is pressed.. woo hoo.. :)
    but one care needs to be taken.
    This will also be called when any link or button on the screen are
    clicked. So be sure to apply some kinda check on the buttons/ links.
    Something like:
    <body onload="flag=true" onUnload="if (flag) alert ('Woo hooo..');">
    <input type=button onclick="flag=false">
    This validation will make sure that on the button click, that logic in
    the onunload thing is not called...
    All the best & keep rockin'
    ~MeTaL~

  • How to cancel the event in Item Adding and display javascript message and prevent the page from redirecting to the SharePoint Error Page?

    How to cancel the event in Item Adding without going to the SharePoint Error Page?
    Prevent duplicate item in a SharePoint List
    The following Event Handler code will prevent users from creating duplicate value in "Title" field.
    ItemAdding Event Handler
    public override void ItemAdding(SPItemEventProperties properties)
    base.ItemAdding(properties);
    if (properties.ListTitle.Equals("My List"))
    try
    using(SPSite thisSite = new SPSite(properties.WebUrl))
    SPWeb thisWeb = thisSite.OpenWeb();
    SPList list = thisWeb.Lists[properties.ListId];
    SPQuery query = new SPQuery();
    query.Query = @"<Where><Eq><FieldRef Name='Title' /><Value Type='Text'>" + properties.AfterProperties["Title"] + "</Value></Eq></Where>";
    SPListItemCollection listItem = list.GetItems(query);
    if (listItem.Count > 0)
    properties.Cancel = true;
    properties.ErrorMessage = "Item with this Name already exists. Please create a unique Name.";
    catch (Exception ex)
    PortalLog.LogString("Error occured in event ItemAdding(SPItemEventProperties properties)() @ AAA.BBB.PreventDuplicateItem class. Exception Message:" + ex.Message.ToString());
    throw new SPException("An error occured while processing the My List Feature. Please contact your Portal Administrator");
    Feature.xml
    <?xml version="1.0" encoding="utf-8"?>
    <Feature Id="1c2100ca-bad5-41f5-9707-7bf4edc08383"
    Title="Prevents Duplicate Item"
    Description="Prevents duplicate Name in the "My List" List"
    Version="12.0.0.0"
    Hidden="FALSE"
    Scope="Web"
    DefaultResourceFile="core"
    xmlns="http://schemas.microsoft.com/sharepoint/">
    <ElementManifests>
    <ElementManifest Location="elements.xml"/>
    </ElementManifests>
    </Feature>
    Element.xml
    <?xml version="1.0" encoding="utf-8" ?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <Receivers ListTemplateId="100">
    <Receiver>
    <Name>AddingEventHandler</Name>
    <Type>ItemAdding</Type>
    <SequenceNumber>10000</SequenceNumber>
    <Assembly>AAA.BBB, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8003cf0cbff32406</Assembly>
    <Class>AAA.BBB.PreventDuplicateItem</Class>
    <Data></Data>
    <Filter></Filter>
    </Receiver>
    </Receivers>
    </Elements>
    Below link explains adding the list events.
    http://www.dotnetspark.com/kb/1369-step-by-step-guide-to-list-events-handling.aspx
    Reference link:
    http://msdn.microsoft.com/en-us/library/ms437502(v=office.12).aspx
    http://msdn.microsoft.com/en-us/library/ff713710(v=office.12).aspx
    Amalaraja Fernando,
    SharePoint Architect
    Please Mark As Answer if my post solves your problem or Vote As Helpful if a post has been helpful for you. This post is provided "AS IS" with no warrenties and confers no rights.

    Recommended way for binding the list event handler to the list instance is through feature receivers.
    You need to create a feature file like the below sample
    <?xmlversion="1.0"encoding="utf-8"?>
    <Feature xmlns="http://schemas.microsoft.com/sharepoint/"
    Id="{20FF80BB-83D9-41bc-8FFA-E589067AF783}"
    Title="Installs MyFeatureReceiver"
    Description="Installs MyFeatureReceiver" Hidden="False" Version="1.0.0.0" Scope="Site"
    ReceiverClass="ClassLibrary1.MyFeatureReceiver"
    ReceiverAssembly="ClassLibrary1, Version=1.0.0.0, Culture=neutral,
    PublicKeyToken=6c5894e55cb0f391">
    </Feature>For registering/binding the list event handler to the list instance, use the below sample codeusing System;
    using Microsoft.SharePoint;
    namespace ClassLibrary1
        public class MyFeatureReceiver: SPFeatureReceiver
            public override void FeatureActivated(SPFeatureReceiverProperties properties)
                SPSite siteCollection = properties.Feature.Parent as SPSite;
                SPWeb site = siteCollection.AllWebs["Docs"];
                SPList list = site.Lists["MyList"];
                SPEventReceiverDefinition rd = list.EventReceivers.Add();
                rd.Name = "My Event Receiver";
                rd.Class = "ClassLibrary1.MyListEventReceiver1";
                rd.Assembly = "ClassLibrary1, Version=1.0.0.0, Culture=neutral,
                    PublicKeyToken=6c5894e55cb0f391";
                rd.Data = "My Event Receiver data";
                rd.Type = SPEventReceiverType.FieldAdding;
                rd.Update();
            public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
                SPSite sitecollection = properties.Feature.Parent as SPSite;
                SPWeb site = sitecollection.AllWebs["Docs"];
                SPList list = site.Lists["MyList"];
                foreach (SPEventReceiverDefinition rd in list.EventReceivers)
                    if (rd.Name == "My Event Receiver")
                        rd.Delete();
            public override void FeatureInstalled(SPFeatureReceiverProperties properties)
            public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
    }Reference link: http://msdn.microsoft.com/en-us/library/ff713710(v=office.12).aspxOther ways of registering the list event handlers to the List instance are through code, stsadm commands and content types.
    Amalaraja Fernando,
    SharePoint Architect
    Please Mark As Answer if my post solves your problem or Vote As Helpful if a post has been helpful for you. This post is provided "AS IS" with no warrenties and confers no rights.

  • How to create the event in the report for jobs scheduling.

    Hi Experts,
    i have a requirement like as follows:
    The following triggers for Batch Jobs in the SCM system will be created.i.     
    Background Processing Event = u201CAPO Background Processing Eventu201D. After sending the Event, write a Log Report line u201CEvent u201CAPO Background Processing Eventu201D sentu201D.
    Could you please suggest me how we create the Event or which transaction ?
    Please give me a steps for creating events so that based on these events we use
    CALL METHOD cl_batch_event=>raise
        EXPORTING
          i_eventid                      = p_bpeve
          i_server                       = p_server
          i_ignore_incorrect_server      = p_ignore
        EXCEPTIONS
          excpt_raise_failed             = 1
          excpt_server_accepts_no_events = 2
          excpt_raise_forbidden          = 3
          excpt_unknown_event            = 4
          excpt_no_authority             = 5
          OTHERS                         = 6.
    Right now i received message "APO Background Processing Event" is doesn't exists.
    Thanks in Advance.
    Puneet.

    Hi Puneet,
    Goto transaction SM62 and in there to BckProcEvents tab. There you can create the events.
    You just need to specify the name and Description of an event.
    Hope this serves your purpose.
    Thanks

  • How can I view my photos in "Events" like in iPhoto? How can I create events?  I have 55,000 photos and 1700 events so the only way I can possibly manage my photos is using events that are one slide in size.

    I have 55,000 images organized into about 1700 events. The only reasonable way to view my library is using events in iPhoto where each event has one image That still leaves 1700 images to sort through but that is a lot easier than 55,000 images.  In the side bar is a folder with "iPhoto Events" but those views still show all of the slides.  How can I create events and view my photos as events as in iPhoto?  Events are critical for large libraries and has been my primary way to sort images.
    Thanks!

    I had a problem a couple of months ago when iPhotos suddenly rearranged the order of my Events (Why won't iPhoto let me arrange my photos?) .  I was told "Use albums not events - events are not a good way to organize - albums and folder are designed for organisation and are very flexible".
    Haha!  I should have paid attention and read between the lines!  My iPhotos were highly organised groupings - not according to date but the way I wanted them - and it was so easy to do!  I see now that if I had them all in albums, as per the Apple Apologist suggestion, I wouldn't have this unholy mess I have been left with just to make iPhone & iCloud users happy.  I am now going through Photos and making Albums (of what used to be in my Events)  ... maybe I'll get this finished before they do another non user friendly update!

  • How can I remove events from my iPhone. I want to delete all the events from my iPhone.

    how can I remove Events from my Photo in iPhone

    Connect to computer iTunes and uncheck under Photos > Events then do a sync.

Maybe you are looking for

  • ITunes won't uninstall or open

    When I click on iTunes, this error message pops up "iTunes cannot run because some of it's required files are missing. Please reinstall iTunes." When I try to install it, it will go through the whole process but it still does not open. When I try to

  • Document in xml - Not serializable? Well, I need to cache it.

    Can anyone tell me how can I serialize DOM Document. When we try to put it in cache, cache complains that it is not serializable (I believe ElementImpl is not Serializable). In javadoc it shows serializable form for this Element, but when I look in t

  • Activating a CARE CODE field in Material Master

    Hi All, I need to activate one field CARE_CODE in MATERIAL MASTER. Can anyone guide me how to activate the same. Let me know if any additional details are required Regards, Raju

  • ERROr- SQL*Loader-704: Internal error: ulconnect: OCIServerAttach [0]

    Hi All, I was running a java program which uses java runtime to call Oracle SQL Loader to load a data file inthe Data base , After loading one file sucessfully , the process stopped after giving the error -: SQL*Loader execution exited with EX_FAIL,

  • Despatch Advice Error

    Hi, We are getting an inbound ASN from the suppllier and the idoc failed due to the following error. V51VP - item was not found - process cancelled Message no. HUGENERAL056 Diagnosis The system did not find the material items that were needed for thi