JFrame.dispose not firing the windowsClosing event

No this one is not quite like the question a few posts down, well not exactly anyway.
I have a JFrame with a windowAdapter that handles my closing tasks, it works just fine currently as long as the close button on the frame is clicked. I had to add a check in the program that should close the window if its true.
So I have code that checks a condition and if its true it shuts down all threads and trys to exit gracefully through the windowClosing event. As other posts have said I can use the jframe.dispose followed by System.exit and it works fine seeing that in the code thoughmakes me think its a kludge since dispose doesn't trigger the windowClosing event. I would like to somehow simulate clicking the close button on the frame when I need to exit because of an error but I'm not sure how to programatically do that.
My current window close operation is set to DO_NOTHING_ON_CLOSE so that the windowClosing event can handle the closing, I tried setting the operation to EXIT_ON_CLOSE then disposing the frame when the error occured but that didn't trigger the windowsClosing event either.
Any ideas?
Thanks,
Eudaemon.

okay... So do something like this:
private void init() { // or whatever...
   frame.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
         quit();
   quitmenuitem.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent.) {
         quit();
public void quit() {
   // do whatever cleanup or checks or whatever...
   frame.dispose();
}

Similar Messages

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

  • Firefox not firing the IOErrorEvent

    Firefox not firing the IOErrorEvent when load fails due to
    unavailability of internet connection in URLLoader.
    I am loading data in my application based on user actions. If
    the user is disconnected and he makes a request for data load, the
    IOErrorEvent tied to the URLLoader object is not being thrown in
    firefox. The same thing works fine for IE where on IOErrorEvent I
    am displaying appropriate message but in case of firefox nothing is
    happening.
    Any ideas about what is going on.
    Rahil

    I guess we don't have a lot of .Net developers on this site.
    Obviously your server-side .Net code has to be translated into corresponding client-side JavaScript in order to add event handlers to the page. And errors running that JavaScript should appear in the Error Console (Ctrl+Shift+j).
    If the console doesn't provide any insight, can you provide a link to the page that has the problem? Then it would be possible to view the code that Firefox actually is (or is supposed to be) executing.

  • How can I display event notes on the relevant event in week/day view?

    Hi folks,
    I'm looking for a way to display the event notes on the actual event in week or day view.
    This will greatly help plan out my week (especially for repetitive events with custom notes for each occurrence).
    I can understand that Apple ommitted this feature to avoid clutter on short-duration events perhaps?
    Clicking on the event (or using the Inspector) to see the notes is not an option. I need an overview that can be viewed at a glance or even printed.
    Looking forward to your suggestions...
    Trev

    Hi Trev,
    With iCal as it is the only suggestion I have would be to add the full text to the title of the events.
    FYI, this is a user to user forum. By posting here you are not guaranteed someone from Apple will read it. If you'd like Apple to know about this I suggest you send them feedback.
    Best wishes
    John M

  • How can I burn a copy of my project to a DVD . I do not have IDVD because I have the Lion os. I did purchase Wondershare for burning but it will not load the iMovie events or projects

    How can I burn a copy of my project to a DVD . I do not have IDVD because I have the Lion OS. I did purchase Wondershare for burning but it will not load the iMovie events or projects

    There is no proper substitute for iDVD.
    Why is there no iDVD on my new Mac?
    https://discussions.apple.com/docs/DOC-3673
    UPDATE & ADDENDUM:
    But even though you can still buy iLife 11 that includes iDVD 7 from Amazon, Apple now make it difficult to install:
    Poster jhb21939 posted this in another thread:
    “when I attempted to load iDVD into a new iMac. A notice came up on the screen stating that the 'Authorisation Licence' had expired on 25 March this year (2012).
    I contacted the Apple support team and eventually, I was told that the Licence had been withdrawn and could no longer be used.”
    In other words Apple are now so adamant that we don’t use iDVD that they have tried to make it impossible to install.
    In response, Old Toad posted this solution:
    “You can still use it one all of your Macs.  If you get an invalid certificate message just set your Mac's clock to sometime before early 2011 and run the installer.  After you're done reset the time back to the correct time.” He added this comment:
    “It began after iDVD and iWeb were discontued and they were dropped from the Apple Store. All I can think of is the certificate was set to expire after a certain time period after the intitial iLife disc was released.
    I've been able to use the installer even without setting back the date.  I just clicked on the Continue button and it would work as expected.  For some it would not continue unless the date was set back.”
    The latest anorexic iMacs just announced do not even include a CD drive! Proof positive that Apple virtually prohibit the use of DVDs - although the newly announced Mac Minis do include a Superdrive.
    Yet, they still include iMovie! Heaven alone knows or understands what you are supposed to do with your newly edited masterpiece - except make a low quality version for YouTube?

  • Can not trigger the null event!

    Page newPage = new Page("ListAffirmSubmit_Java");
    EventResult result = new EventResult(newPage);
    return result;
    This way can not trigger the null event in the 'newPage'.I want to call the null event to init the viewobject in the 'newPage'.
    Can you tell me the reason or another way to init it?

    I have found a way from the help on line:
    Page nextPage = new Page("ListAffirmSubmit_Java");
    Page redirectPage = RedirectUtils.getRedirectPage(context, nextPage);
    return new EventResult(redirectPage);

  • My iphone calendar wont sync with my outlook calendar. My inbox seems to be syncing just fine, its just that my iphone calendar is not showing the same events i have in outlook.

    my iphone calendar wont sync with my outlook calendar. My inbox seems to be syncing just fine, its just that my iphone calendar is not showing the same events i have in outlook.

    Hi
    I have the a similar problem - only I can't actually get the calendar to show up. I've added the account and it's showing Mail and Notes but not Calendar. But I'd like it to show the outlook calendar.
    I'm going to
    Go to settings > mail contacts calendar
    select your account that's affected
    But under that account there isn't a calendar showing and I can't see any options to add it?

  • Firing the custom event dynamically

    Hi All,
      is it possible to fire the cutomevent IWDCustomEvent dynamically.Basically i have 2 buttons with their actions, on clicking  buttonA it does some logicA and when somecondition is met it should also do buttonB Action without userinteraction on buttonB
    public void onActionButtonA(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionAddPlan(ServerEvent)
        wdComponentAPI.getMessageManager().reportSuccess("button 1 clicked:");
      if(conitionismet)
         it should dynamically call the onActionButtonB, for this how can i pass IWDCustomEvent  instance
        //@@end
    public void onActionButtonB(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionAddPlan(ServerEvent)
        wdComponentAPI.getMessageManager().reportSuccess("buttonaction);
        //@@end
    i cannot put the same LogicB inside the condition of if(conitionismet) of onActionButtonA.
    So is it possible for fire an event onaction of a button dynamically without user interaction.
    Thanks,
    pkv

    Hi,
    You can just execute your function inside the "IF" clause:
    public void onActionButtonA(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
    //@@begin onActionAddPlan(ServerEvent)
    wdComponentAPI.getMessageManager().reportSuccess("button 1 clicked:");
    if(conitionismet) {
    onActionButtonB(wdEvent);
    //@@end
    public void onActionButtonB(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
    //@@begin onActionAddPlan(ServerEvent)
    wdComponentAPI.getMessageManager().reportSuccess("buttonaction);
    //@@end

  • Why do I not catch the FocusLost Event in the JPasswordField

    I write a subclass of JPasswordField, which does some functions when it loses the focus. But, it dosen't work. How to make it work?
    <The same method work well for JTextField>
    Here is the sample code
    public class MyPasswordField
    extends JPasswordField
    implements FocusListener
    public void focusGain(FocusEvent e){}
    public void focusLost(FocusEvent e)
    // method body
    logger.debug("focus lost - caught!");
    // constructors
    I am wishing the "focus lost - caught!" could be printed out!!
    Thanks

        public class MyPasswordField   extends JPasswordField  implements FocusListener {
            public MyPasswordField(){
                addFocusListener(this);
    // ....

  • I downloaded 1100 photos from Kodak Easy Share to Iphoto. Now when I open the photo events in the photo library, a thumbnail screen of all the pictures appears. However, when I click on a thumbnail photo to enlarge it, a lock symbol appears. Help!

    I downloaded 1100 photos from Kodak Easy Share to the Iphoto library. Now when I open

    If Larry's suggestion re iPLM doesn't help there's always the last ditch effort solution:
    Starting over from scratch with new library
    Start over with a new library and import the Originals (iPhoto 09 and earlier) or the Masters (iPhoto 11) folder from your original library as follows:
    1. Open the library package like this.
    2. Launch iPhoto with the Option key held down and, when asked, select the option to create a new library.
    3. Drag the subfolders of the Originals (iPhoto 09 and earlier) or the Masters (iPhoto 11) folder from the open iPhoto Library package into the open iPhoto window a few at a time.
    This will create a new library with the same Events (but not necessarily the same Event names) as the original library but will not keep the metadata, albums, books slideshows and other projects.
    Note:  your current library will be left untouched for further attempts at a fix if so desired.

  • Events not showing up in Event Library

    I have been working on importing a bunch of video from my DV camera and all has gone well up to this point. The next time I opened iMovie my events did not show up in the event library. When I look on the Finder I still see the clips in the iMovie event folder, but they are not in my event library. All I see in my event library is my iPhoto video and an option to open the Last Import (although nothing is there). Even when I import new video now, I can still find it in the finder, but not in the iMovie event library.

    Talked to Apple support- we figured it out. In case anyone has the same problem: one of my events in the iMovie events folder was corrupted, once I deleted that file, all was well.

  • Tirgger not firing sometimes

    Hi,
    Here is the problem:
    Table A has 4 triggers and one of them is updating a field in table B. On all but one installation table B does not get updated all the time. (We have this code on different versions of Oracle on Solaris, Windows and Linux)
    From the triggers one is on delete and the other three are on "insert or update" including the one, which is supposed to update the B table. A simple update of the record usually takes care of the problem meaning that the trigger gets fired and the B table gets updated. At one point I had to run the update two times for the trigger to fire but I have not been able to reproduce this (update not firing the trigger)
    There is nothing to disable the triggers. We have not been able to find anything special about the records, which when inserted in A and for which the trigger did not fire at the time.
    Could it be that the existence of several triggers all of which are on "insert or update" causes the problem? What else can we look into? It is rather annoying because it happens only every so often and it is usually discovered days after the fact.
    Thanks,
    Jivko

    HI,
    Generally if the trigger size exceeds 64K, it may not fire for the given action even though it is a right action. What i will suggest you is, Please split your "insert OR update" trigger into two different individual triggers, i.e, one with insert and another with update. Even if it exceeds, incorporate some of the functionality into PL/SQL block (procedures) and call it inside the Trigger.
    Regards,
    G. Rajakumar.

  • Autocomplete search appearing but search not firing?

    I am using the following in my interactive report to provide an autocomplete Jquery search fields
    When typing in an item in the search boxes the autocomplete works find but for some reason it is not firing the search anymore? Any ideas on what I am missing with this? I have spent the week on it and it would be great to sign off the week with a working report!
    Many Thanks
    In the Javascript section of the page I am using
    function srch2(pItem, pColumn) {  
    $.post('wwv_flow.show',
    {"p_request" : 'APXWGT',
    "p_widget_action" : 'FILTER',
    "p_widget_action_mod" : 'ADD',
    "p_widget_mod" : 'ACTION',
    "p_widget_name" : 'worksheet',
    "p_flow_id" : $v('pFlowId'),
    "p_flow_step_id" : $v('pFlowStepId'),
    "p_instance" : $v('pInstance'),
    "x01" : $v('apexir_WORKSHEET_ID'),
    "x02" : $v('apexir_REPORT_ID'),
    "x03" : pColumn,
    "f01" : ['COLUMN', pColumn, '=', $v(pItem), null, 'minutes']
    function(data){
    //when the filter has been successfully applied the report has to be refreshed
    if(data=="true"){
    gReport.pull();
    //clear the item
    $s(pItem,'');
    $('#P4_AC').bind("result", function(){   
    //on selecting a value then fire the search function
    srch2(this, 'INDSNAME');
    // ac item P4_AC2
    $('#P4_AC2').bind("result", function(){   
    srch2(this, 'INDFNAME');
    // ac item YEARD
    $('#YEARD').bind("result", function(){
    srch2(this, 'NEWYEAR');
    });

    Nico Martens wrote:
    Console the most left tab of firebug. It shows all dynamic actions that are firedyes, exactly. Open up firebug and watch the console. Ideally, when selecting a value from the autocomplete 2 ajax calls should appear. The first one is the one to apply filters, the second on if the refresh (report pull). You can easily identify them through watching the headers. Be sure to check out the response tab for the 'apply filter' ajax: the response should be 'true'.
    If no ajax call pops up however, the problem is with the onSelect of the autocomplete and/or the search button.

  • When-tab-page-changed not firing

    I have 2 seperate forms opened on a single page. One displays on left side of screen and has tabs. One display on right side. If I am currently on my right side form (no tabs) and click on a tab on the left side form, it seems the 'When-tab-page-changed; trigger is not firing the first time. I have tried this on 6i and 10g webforms. If I try it on client/server 6i it works. Any suggestions?

    I just tried this with 10gR2 in web. My form with the tabs only get focus and does not call when-tab-page-changed when you click on a tab after returning from the other form.
    A 2nd button press does then call the when-tab-page-changed.

  • The apexafterrefresh event not being fired in Chart IR's

    Hi all,
    I am adding additional functionality to IR reports using the plug-in architecture in Apex 4.1.1. A Dynamic action has been added to the "After Refresh" event for the #apexir_WORKSHEET_REGION jQuery selector.
    This works fine in all cases except when no data is found in the report. This has been fixed in 4.2 so I can live with this until the upgrade. However, it also does not work when a chart is created in the report, the apexafterrefresh event does not get raised. Therefore my dynamic action will not fire. Looking at the apex_interactive_reports_4_1.js this event gets raised for the table element with an ID stored in apexir_WORKSHEET_ID ie:
    apex.jQuery('#' + $v("apexir_WORKSHEET_ID")).trigger('apexafterrefresh', that.report_id);However this table element does not get rendered when a Chart is displayed and therefore the apexafterrefresh will not get raised.
    In apex 4.2 the widget.interactiveReport.js has been modified to handle the no data found but not charts:
    var lTriggeringElement$, lWorksheetId;
                            lWorksheetId = $v( "apexir_WORKSHEET_ID" );
                            if ( $x( lWorksheetId ) ) {
                                // If the table element containing data exists (ie when the report returns rows),
                                // use that to trigger the event.
                                lTriggeringElement$ = apex.jQuery( '#' + lWorksheetId );
                            } else {
                                // Otherwise, use the span holding the no data found message.
                                lTriggeringElement$ = apex.jQuery( '#apexir_NO_DATA_FOUND_MSG' );
                            lTriggeringElement$.trigger( 'apexafterrefresh', that.report_id );I have created a test case on apex.oracle.com - http://apex.oracle.com/pls/apex/f?p=41357:1 In this example I simply display an alert from a Dynamic action with the following attributes:
    Event - After Refresh
    Selection Type - Region
    Region - Interactive Report
    As can be seen when the user navigates to the report the alert displays, however when you navigate to the Chart the alert does not display.
    In my mind this is a bug and the IR reports JavaScript should be modified to raise the event apexir_WORKSHEET DIV Element instead. This would fix both issues.
    Any ideas on how to overcome this issue?
    Thanks
    Chris.

    For everyone's information Bug 16029272 - ALERT (APEXAFTERREFRESH EVENT) NOT BEING FIRED IN CHART OF INTERACTIVE REPORTS has been raised regarding this issue.

Maybe you are looking for

  • Photoshop cs2 to dreamweaver 8

    I know this will be a very simple question for some people, but am wondering if there is an easy answer to my question. I am a graphic designer running creative suite 2 on the mac, and although I am not totally stupid I still have issues with a few b

  • How to implement a linked list in oracle ?

    HI All I want to know if there a way to implement a linked list in oracle ? Thanks in Advanced Naama

  • Problem Installing AccessManager6.x in AppServer8.1. Need how to.

    Successfully installled AM into WebServer, but if I choose AppServer as container......I fail....help. 1. I installed JES2005Q1 AppServer8.1, this is a standalone tar file fr sun.com 2. started install of AccessManager, this is a standalone tar file

  • Payment done - no creditts

    i had a subscription it was for one month but the minits finsh befor the month ends so i have maid another  payment today morning and purchase history showing deliverd but no credit showing why this issue how can i solve the probelm.

  • SMA Class- Get_Instance_Infos

    Hi All,    For the Shared Memory Area, I am trying to use a method: Get_Instance_Infos. Maybe I'm missing it because it's late.. not sure.    I get an error message saying:    Program Zxxxxyyyyzzzz    Formal Parameter "INFOS" is not a EXPORTING param