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();
});

Similar Messages

  • Unable to stop the event logs on access point console

    Hi team,
    I have an AIR-LAP1131AG-E-K9 access point having ios c1130-k9w8-mx.124-21a.JHB1.
    When I am trying to take the console of it there are many logs generated like LWAPP ...Go join the controller, Discover controller etc. and the ap is unable to register to the controller(2112 with ios version 6.0.199.4). I'm trying to enter the command but there are many event msg generated....How do i stop this event log. I tried entering the command no debug all. but still there are many logs...
    I want to enter the the following commands
    #lwapp ap  ip address <ip addr>.
    #lwapp a pip default-gateway <gateway ip addr>
    #lwapp ap controller ip addr <controller ip>
    #wr me
    Revert me back on urgent basis
    Thanks in advance..

    Thanks Rashika,
    Now the access point got registered to the controller..This happened becuse of country Code..
    I have changed the country code to UK, Belgium it started working fine.
    Initially when it was IN the access point was not getting register..
    But now the problem which arised is that the user is unable to get authenticated to the radius server.
    Radius server is reachable and we have done every changes required for radius server authentication.
    Users are getting rejected.
    Customer is saying that the radius server is in IN domain and the WLC/access point is in UK,BE and hence the users are unable to connect..
    Is it so??
    Rply
    Thanks in advance...

  • ICal has stopped showing events for Sundays only in the month view.

    iCal has stopped allowing events to be entered or viewed on Sundays from the Month view.  If I double click on a date on the month view, for a Sunday, nothing happens on the screen but if I go to the day view there is a default New Event on the day. 
    If I enter an event from the day view it does not appear on the Sunday in the month view.
    On previous Sundays where events already exist I can add a new event from the month view.  If I add an event using google calendar from Chrome it appears on the Sunday and then I can add event from the month view.
    This just recently started happening.
    I am using Mavericks 10.9.1 with iCal Version 7.0 (1835.1).

    dutchlab,
    Quit Calendar, then try removing the com.apple.iCal.plist file from your Macintosh HD/Users/yourusername/Library/Preferences Folder. To find that folder, use Finder>Go Menu>Depress the "Option" key>Library, and open the Preferences Folder. Drag the com.apple.iCal.plist file to your desktop, and log out/in or restart and check Calendar for functionality.

  • How to stop timeout event

    hi,
    Inside a while loop i've placed one timeoout event with other button click event, but after stopping the while loop the time out event didn't stop.. how to stop that event,
    Suggestions pls??
    Thanks and Regards
    Jagan

    2716jag wrote:
    im having only one event structure.. see within a while loop im having the event structure. im having three cases, one is time out event having the time out of value '0'. that is it never wait for other to event occur. if i click other other event after running that time out event is running. in one case im stoping the while loop with a boolean. but after giving the true value to the while loop the time out event is continously running. tell me how an i stop the time out event??
    You should really show us your code! We cannot troubleshoot vague descriptions. Attach your VI or at least attach a picture of the code.
    Have you tried running in execution highlighting mode?
    Some guesses:
    Are you possibly running the VI in "continuous run" mode? That would restart the code after it finishes. 
    Is your stop button outside the loop, but wired to the stop terminal across the loop boundary?
    Message Edited by altenbach on 06-15-2008 01:48 AM
    LabVIEW Champion . Do more with less code and in less time .

  • Calling a JDialog in the windowClosing Event of a JFrame

    hi
    As we had seen in many applications when u try to close the application a Dialog box will appear and it will ask whether we have to save it.I want to implement the same thing in my windowClosing Event of the Frame.I tried doing this by calling the Dialog i have created by using the show method in the window closing event of the Frame,but what happens is when i close the frame the Dialog box flickers and disappears.What should i do to avoid this flickering and Disppearing of the Dialog box.I want the Dialog box to stay on the screen.What should i do? any ideas?
    thanks

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class WindowClosingTest extends JFrame {
         public WindowClosingTest() {
              try {
                   setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
                   JButton button = new JButton("Close");
                   button.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent ae) { performClose(); }
                   addWindowListener(new WindowAdapter() {
                        public void windowClosing(WindowEvent we) { performClose(); }
                   getContentPane().add(button);
                   pack();
                   setLocationRelativeTo(null);
                   setVisible(true);
              } catch (Exception e) { e.printStackTrace(); }
         private void performClose() {
              int n = JOptionPane.showConfirmDialog(null, "Close?", "Confirm", JOptionPane.YES_NO_OPTION);
              if (n != 1) { System.exit(0); }
         public static void main(String[] args) { new WindowClosingTest(); }
    }

  • Can I stop the event to add an entry with the event et_FORM_DATA_ADD???

    My problem is when i add a record , for example a BusinessPartner. I want to stop the event  et_FORM_DATA_ADD  when not comply  a condition.This is my code:
    Private Sub SBO_Application_FormDataEvent) Handles SBO_Application.FormDataEven
    Dim IC As SAPbobsCOM.BusinessPartners
    If BusinessObjectInfo.EventType = SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD And  BusinessObjectInfo.BeforeAction = False Then
          Select Case BusinessObjectInfo.Type
          Case 2 // BusinessPartners
                IC = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners)
                IC.Browser.GetByKeys(BusinessObjectInfo.ObjectKey)
                Dim ZP As String = IC.ZipCode
                if ZP  = "99999"
                  // STOP. I Dont want to add this record.how can stop it??    
                 End if
    End if
    Thanks.

    Hi Edy;
    From what my understanding is that you want to stop this Add event if the user type in something wrong in the form.Is this correct ? if so, can you tell me which field ? maybe I can help you with some code.
    Remember the code:
    If BusinessObjectInfo.EventType = SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD And BusinessObjectInfo.BeforeAction = True Then
    IC = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners)
    IC.Browser.GetByKeys( BusinessObjectInfo.ObjectKey )
    //open Form1
    oXmlDoc.Load(NameForm)
    creationPackage = SBO_Application.CreateObject   (SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams)
    creationPackage.XmlData = oXmlDoc.InnerXml
    oForm1 = SBO_Application.Forms.AddEx(creationPackage)
    dim Class as NewClass = new (oForm1 ,IC)
    // STOP. I Dont want to add this record until the Form1 get me a value. This value I have to selected from a Grid on the Form1, so until I select it I can't continue with the execution, because I need to assign to the IC
    // assign to the IC the Value
    IC.UserFields.Fields().Item("UserField").Value = Class.Value  
    End if
    Thank you very much Edy

  • We stopped receiving event about lockout users after we installed rollup 4 for tmg with sp2

    We have implemented Account Lockout Feature in TMG 2010 (http://www.ntsystems.it/post/ActiveSync-ForeFront-TMG-and-AccountLockoutThreshold.aspx). We configured
    alert definition to send alert when problem occure. After we installed rollup 4 we stopped receiving  event about this probloem ("The limit of consecutive logon failures has been reached...."). How can we resolve this problem? We have implented
    a script which send this information automatically to user with problem. This is very important for us.
    Event description:
    Source: Microsoft Forefront TMG Web 
    Event ID: 32581
    Level: Error
    Text: limit for consecutive logon failures has been reached. Additional logon attempts by domain.local\user.name will be automatically rejected for the next 300 seconds

    Hi,
    Before going further troubleshooting, we should confirm if account lockout works fine now.
    Please refer to the article below to check some limitations on this function.
    http://blogs.technet.com/b/isablog/archive/2012/11/01/using-the-account-lockout-feature-in-tmg-2010.aspx
    Is there any other different information after you install Rollup 4? Or what something else do you change during update to RU4?
    Best Regards
    Quan Gu 

  • Stopping an event propagation

    Hi!
    I want to provide hotkey in my html webpage. (I am using
    http://code.google.com/p/js-hotkeys/)
    I also have a chat module in Flex. When I am typing some text
    in the flash object, I don't want the hotkeys to be enabled.
    I tried to stop the propagation from the flash but it's not
    working.
    From what I know, the html events are propagated from the
    child to the parents. So if I stop the event from my flash object
    it has to be ok, right?
    See my example. If I display an Alert from the callback, it
    is displayed, so it works. Why the event is still propagated?
    Thanks

    "Jimmy Jeeves" <[email protected]> wrote in
    message
    news:g8va3c$ak4$[email protected]..
    > Hi!
    >
    > I want to provide hotkey in my html webpage. (I am using
    >
    http://code.google.com/p/js-hotkeys/)
    > I also have a chat module in Flex. When I am typing some
    text in the flash
    > object, I don't want the hotkeys to be enabled.
    >
    > I tried to stop the propagation from the flash but it's
    not working.
    >
    > From what I know, the html events are propagated from
    the child to the
    > parents. So if I stop the event from my flash object it
    has to be ok,
    > right?
    >
    > See my example. If I display an Alert from the callback,
    it is displayed,
    > so
    > it works. Why the event is still propagated?
    >
    > Thanks
    >
    > public function reportKeyDown(event:KeyboardEvent):void
    > event.preventDefault();
    > event.stopPropagation();
    > }
    >
    > this.addEventListener(KeyboardEvent.KEY_DOWN,
    reportKeyDown);
    >
    I don't think you can preventDefault on key events. You could
    probably use
    ExternalInterface to tell the web page not to listen for the
    hot keys for a
    while, though.
    HTH;
    Amy

  • Can I stop the event to add an entry??

    Can I stop the event to add an entry if this entry does not comply with a condition that I make?
    I can catch th event to add an entry, but i want to stop it and i dont know how to do it?
    anyone can help me ??
    Thanks.

    Hi,
    Try the following...
    1) In the Add button click in the before action TRUE part u check the condition and validate.
    If ur condition is False..
    then Exit sub
    Else
    MsgBox("Fill the required info corectly")
    BubbleEvent = False
    I wrote this code:
                If pVal.FormType = 134 And pVal.ItemUID = "1" And pVal.EventType =   SAPbouiCOM.BoEventTypes.et_CLICK  And pVal.BeforeAction = True Then
                    Dim o As Boolean = False
                    If o = False Then
                        Exit Sub
                    Else
                    End If
                End If
    where FormType  = 134 is BusinessPartner. When add record I capture this event but  added the IC to BBDD, otherwise would have to stop using the event et_FORM_DATA_ADD??
    thanks.

  • How to stop Timer event inside movie clip that does not exist?

    Hello. I am using Adobe Flash CS6.
    As this topic title says. how to stop Timer event nside movieclip that does not exist?
    I mean my fla stracture is  there are 2 frames on main timeline, and I put mcA on frame 2.
    And I put a button on root that does
    if(currentFrame ==1)
    gotoAndStop(2);
    else if (currentFrame ==2)
    gotoAndStop(1);
    And mcA has AS inside and it is
    var T_Timer:Timer = new Timer(1000,0)
    T_Timer.addEventListener(TimerEvent.TIMER, test)
    function test(e:TimerEvent):void{
    trace("Timer active")
    T_Timer.start();
    I need to stop T_TImer from root on frame 1, not on frame 2.
    but, "mcA.T_Timer.stop();" won't work.
    I get TypeError: Error #1010 error.
    I don't know how to stop this timer event. I have to stop it from root, and I can't use EVENT_REMOVED in this case.

    If the object doesn't exist you cannot do anything relative to targeting it.  Maybe you should move the timer to the main timeline where you can access it any time.

  • 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

  • Help !! needed with windowClosing() event

    Hi there I have a problem were I would like to shut down my application when it is iconified,
    THE SHORT STORY
    I would like my application to be deiconified when I close it by right click in its icon and select the close option.
    BACKGROUND
    the current situation is when it is iconified I can right click and then I get the menu where I can choose to restore or close, when I click close, a windowclosing event is fired but nothing happens the application is not shut shown, when I then right click again and restore the app I notice that my own built in logout menu is up so it seems to be recieving the event all I want is the appp to be deiconified when I clik close.
    As I am a distributed programmer this gui stuff is rocket science i would appreciate any help

    Something like the following, though I am not sure too.
         win.addWindowListener(new WindowAdapter() {
              public void windowClosing(WindowEvent e) {
                   // Invoked when a window is in the process of being closed. The close operation can be overridden at this point.
                   Window win = e.getWindow();
                   boolean iconified = win.getState() == ICONIFIED;
                   if (iconified) {
                        e.consume();
                        win.setState(NORMAL);
                   } else {
                        super.windowClosing(e);

  • JDialog dispose() not firing windowClosing()/windowClosed() event

    I have a small dialog that has 'OK' and 'CANCEL' buttons. When the user clicks on the 'X' in the top right hand corner to close the window, the windowClosing() event is fired on all listeners. However, calling dipose() when i click on the 'OK' or 'Cancel' buttons does not fire the event. I am sure this should work without a problem but i just cannot see what is going wrong.
    Andrew

    I'd have to test this, but there's some sort of logic to think that calling hide or dispose would not generate events. What would be the point? You know it's going to be closed, so you should tell anyone who needs to know. You can get the list of listeners and fire your own event if you wanted.
    Window.dispose() does fire a window closed event, though.
    If you want to simulate closing... This is from code I had written... some of it you can replace as appropriate (isJFrame(), etc).
          * Closes the window based on the window's default close operation. 
          * The reason for this method is, instead of just making the window
          * invisible or disposing it, to rely on either the default close
          * operation (for JFrames or JDialogs) or rely on the window's other
          * listeners to do whatever the application should do on the "window
          * closing" event. 
         private void doClose() {
              int closeOp = getDefaultCloseOperation();
              // send the window listeners a "window closing" event... 
              WindowEvent we = new WindowEvent(getWindow(), WindowEvent.WINDOW_CLOSING, null, 0, 0);
              WindowListener[] wl = getWindow().getWindowListeners();
              for(int i = 0; i < wl.length; i++) {
                   // this handler doesn't need to know...
                   if(wl[i] == this) {
                        continue;
                   wl.windowClosing(we);
              // if still visible, make it not (maybe)...
              if(getWindow().isVisible()) {
                   switch(closeOp) {
                        case WindowConstants.HIDE_ON_CLOSE:
                             getWindow().setVisible(false);
                             break;
                        case JFrame.EXIT_ON_CLOSE:
                        case WindowConstants.DISPOSE_ON_CLOSE:
                             getWindow().setVisible(false);
                             getWindow().dispose();
                             break;
                        case WindowConstants.DO_NOTHING_ON_CLOSE:
                        default:
         * Gets the default close operation of the frame or dialog.
         * @return the default close operation
         public int getDefaultCloseOperation() {
              if(isJFrame()) {
                   return ((JFrame)getWindow()).getDefaultCloseOperation();
              if(isJDialog()) {
                   return ((JDialog)getWindow()).getDefaultCloseOperation();
              // "do nothing" is, for all intents and purposes, the way AWT
              // Frame and Dialog work.
              return WindowConstants.DO_NOTHING_ON_CLOSE;

  • Custom agent stops receiving events after long period

    What would cause a custom agent to stop receiving events?
    I have two custom agents that register to listen for events from PublicObject. These agents run along with some custom timed-based agents in a ServerManager instance.
    After about eight days, events are not being sent to the custom agents. The timed-based agents run fine after this period.
    I have observed that if the CUPServer is running this will stop events being sent to the custom agents. The CUPServer was not running for the above case.

    I can't think of anything that would cause that.
    Do you want to post your code, and see if anyone detects any problems?

  • How to stop frame from closing in windowClosing event ?

    I have an application which will download some files from the web.
    If the user attempts to close the applicaiton and if some files donwload action is in progress then i need to warn the user and prevent the window from closing. This is what i have done. But what happens is message box is displayed and my window is getting closed. How to get rid of this ? need your help...
    frame.addWindowListener(new WindowAdapter() {
                   public void windowClosing(WindowEvent we) {
                        if(DownloaderGUI.tableModel.isSomeThingDownloading()) {
                             JOptionPane.showMessageDialog(null,"cannot close when something is downloading");
                             return;
                        System.out.print("closing..");
                        backEndThread.setCanQuit(true);
                        cleanUp();
                        System.exit(0);
              });

    I have also done a similar things but still window is getting closed.
    public void actionPerformed(...)
    if(!canquit) {
          return;
    } else {
          System.exit(0);
    }Message was edited by:
    chaos_begins_here

Maybe you are looking for

  • Getting a hp mce remote for touchsmart 300-1125

    I want to add a remote control to my HP Touchsmart 300-1125 and am thinking to order the 5070-5600 HP remote (random link: http://cgi.ebay.com/HP-COMPAQ-5070-5600-Media-Center-Remote-Control-/330414657906#ht_805wt_911). I wonder about two things: 1)

  • How to create dynamic numbering in report?

    Hi all, Can we generate a dynamic numbering of records that appear on report depending how many record queried? For example if the query return 5 records than we will add the number from 1 to 5 at the beginning of the record. If 8 records returned th

  • Adobe Reader/Acrobat forms issues!

    This is a long one, and I know it's been posted before, but I just wanted to try again anyway. I've just created a form using Adobe Designer, one that contains fields that someone can fill out when the form is open with Adobe Reader. The form I've cr

  • Excise Duty Rate Chnge -No CIN

    Hello Changes in budget rate for excise.PO with old rate already entered.No CIN.Need to write a validationor (how can i do it) that On MIRO,if tax rate(which has been manually enterd in PO) is 16%,should change to 14%(shud i create a new Tax code for

  • Changing a number in a biljart ball

    Hi, I want to go from ball 13 to ball 1. Changing the color is no problem. But changing the numbers is. Any advice is appreciated.