Execute Code on closing frame

Dear friends,
I would like to know how to execute code on closing the frame.

          JFrame frame = new JFrame();
          WindowListener l = new WindowAdapter() {
                    public void windowClosing(WindowEvent e) {
                         // Do here what you want ...                    }
          frame.addWindowListener(l);

Similar Messages

  • Execute code when IE Browser closes

    Help!  I'm trying to find a way to run a SQL statement when a user closes a IE window (X's out).  I've found information on the onBeforeUnload event but I've been unsucessful at getting it to run.
    Does anyone have another suggestion?  Is it even possible to execute code upon closing a window?
    Thanks!!!

    Thanks ilssac.  I figured this was the case based on my research but I thought I'd present it to the Forum just to be sure.
    Basically, I've been asked to limit the number of logins to a small Coldfusion application.  I've coded it so that I increment a counter in the DB and I decrement it when the user logs out properly (by clicking a logout link).  But if the user just closes the window then the decrement doesn't happen and this created problems.
    If you have any suggestions I would really appreciate it.
    Thanks for your time!!!!

  • Cannot execute year-end closing in IDES R/3 4.71

    Hi Gurus,
    I am working with IDES R/3 4.71.
    since the current fiscal year in system in 2003, i try to change the fiscal year to 2004, then 2005, ..., finally I wish to get fiscal year 2009.
    during the procedure, i need to post AA depreciation for each period of 2003. I have done that successfully with AFAB. then I also successed with Change Fiscal Year to 2004. now I need to execute year-end closing for 2003. but the system reports errors.
    error message like below:
    =========================================================
    Asset balance sheet values not completely posted
    Message no. AU075
    Diagnosis
    In company code 1000, which is to be closed, APC values have not been posted to Financial Accounting for all relevant depreciation areas.
    Depreciation area 03, at least, is set up for periodic posting of APC values.
    The year-end closing checks if documents were posted that have an entry date after the last run of the program for periodic posting of APC values. If such documents are found, the system issues this message.
    Procedure
    Check which depreciation areas are supposed to post APC values periodically to Financial Accounting according to their Customizing definitions (indicator: "Post assets periodically in General Ledger")
    See the Define How Depreciation Areas Post to General Ledger IMG activity.
    Start the program for posting APC values. In the Asset Accounting main menu, choose Periodic processing . Start this program in update mode, regardless of whether or not documents are displayed in test mode, or if a message appears stating that there are no documents to be posted.
    Start APC Posting Program
    ==================================
    I didn't change the depreciation area provided by IDES group.
    anybody knows what's wrong?
    many thanks!
    George

    George,
    The long text seems to be self-explanatory. IDES comes with pre-configured stuff. So for sake of training they may have designated some depreciation areas as periodic posting. Please follow the instructions in the message and try to resolve it.
    If I were you:
    a) I would find out the chart of depreciation for the company code you are trying to do a fiscal year close.
    b) Then go to the configuration and see the definition of each depreciation area.
    c) For those which have periodic posting of depreciation, run the corresponding program as instructed in the long text.
    Regards,
    Vishal.

  • Labview code for closing the command window

    Hi,
    This is naveen.Actually we are using 3rd paty test software for our mobile hardware testing which creates an DOS or Command window after execution.We have automated to execute this software using labview.the problem we facing is that we couldn't run the test software unless we close or kill the dos window opened in the previous run.So i like to know whether you have any labview code for closing or killing the DOS window ,i request you help me in this regard.
    regards,
    Naveen 

    Use the System Exec VI Owning Palette: Libraries & Executables VIs and Functions.
    And take a look here http://www.tech-recipes.com/rx/446/xp_kill_windows_process_command_line_taskkill/
    Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
    (Sorry no Labview "brag list" so far)

  • Need help on closing frame

    I have a new frame that opens from a menu and I want to be able to push a button and have that frame (the frame the button is in) to close, kind of like a cancel button so you push cancel and nothing happens except the frame closes.
    Here is my code for this frame:
    public class Logout extends JFrame
        JPanel contentPane;
        BorderLayout borderLayout1 = new BorderLayout();
        GridBagLayout logoutGridBag = new GridBagLayout();
        JButton buttonLogout = new JButton();
        JButton buttonCancel = new JButton();
        public Logout()
            try
                jbInit();
            catch (Exception exception)
                exception.printStackTrace();
        private void jbInit() throws Exception
            contentPane = (JPanel) getContentPane();
            contentPane.setLayout(logoutGridBag);
            buttonLogout.setText("Logout");
            buttonCancel.setText("Cancel");
            //Cancel Logout, return to main menu
            buttonCancel.addActionListener(new ActionListener()
                public void actionPerformed(ActionEvent evt)
            contentPane.add(buttonCancel,
                            new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0
                                                   , GridBagConstraints.SOUTHEAST,
                                                   GridBagConstraints.NONE,
                                                   new Insets(9, 10, 7, 3), 4, 51));
            contentPane.add(buttonLogout,
                            new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
                                                   , GridBagConstraints.NORTH,
                                                   GridBagConstraints.NONE,
                                                   new Insets(8, 16, 4, 17), 2, 52));
    }Thanks
    Scott

    Well not sure what else I can try to get this frame to close.As I said you should be using a JDialog not a JFrame
    Problem is that the whole application closes and not just the frame I have up.So create a [url http://www.physci.org/codes/sscce.jsp]Simple Executable Demo Program that shows this behaviour. That way we don't have to guess what you are doing. You should be able to do this in about 15-20 lines of code and you will learn alot:
    a) create a JFrame with a JButton on it.
    b) add code to the button to create a display a JDialog
    c) on the JDialog add a JButton to close the dialog
    Read the [url http://java.sun.com/docs/books/tutorial/uiswing/TOC.html]Swing Tutorial if you need help with any of these basic steps to GUI building.

  • The request to execute code in the sandbox failed

    I have developed a webpart for a client which is hosted on
    O365.
    While saving the webpart properties I am Getting the error"Web Part Error: The request to execute code in the sandbox failed."
    The same web part works on a different O365 site perfectly fine.

    Try below article
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/70b13a7f-c9f8-4bf9-8229-670472959e60/web-part-error-sandboxed-code-execution-request-failed?forum=sharepointdevelopmentprevious

  • It is possible to programmatically disable the "Executing Code Modules in an External Instance of CVI" feature?

    It is possible to programmatically disable the "Executing Code Modules in an External Instance of CVI" feature within a CVI project?
    I know how to do it manually (Configure > Adapters... > Adapter Configuration).
    Thanks in advance,
    --M

    Yes. TestStand 2.0 added the Engine.CVIAdapter_ExecuteStepsInCVI property.

  • Executing code on EXIT_ON_CLOSE

    I was wondering how you execute code when a JFrame closes using the X button (ie, without using a menu). Because you don't attach an ActionListener to it, I am unsure as to where I would place code that I would like to execute before the program exits.
    Thanks

    add a WindowListener to the JFrame; windowClosing() will be called when the X is clicked (setDefaultAction is more or less just a convenience method for this)

  • Flash CC to canvas and spreading code over several frames

    I know about the relationship between flash and CreateJS, and I know that I could step away from the flash interface for A LOT of what I'm after and simply use it to create a nifty library of assets and have all my javascript as external files. That's not what I'm after (although using a text editor with proper syntax highlighting would be wonderful!). I wish to keep as much of my workflow as possible inside of the Adobe Flash CC interface.
    The question comes in two parts, the second being a followup question:
    1) Where I before used to save code in external as files, since now the external javascript gets created (combined) when publishing the flash project, I thought I'd better keep all my code inside of flash. Is this a mistake? I'm after ease of use and keeping my projects structured.
    2) If I keep my code inside of flash I'd never nest it in movieclips. I'd keep it all on the main timeline strictly. Back in the golden flash days for decent but smaller apps I'd put general helper functions and imports on the first frame, then maybe some preloading graphics on frame 2 with minimal code for that. Finally "the app" on frame 3 with more specific code to manage the interface. This made everything load quickly and I could spread the app functionality naturally over a few frames to make it easier to visualise and manage. But exporting for canvas/javascript I can't even get code on one layer to recognise the functions on another. Do I really need to scope main timeline functions on creation to get it to work?
    I'm really after basic advice on workflow and project structuring.
    Thanks!

    1) that's a strange question considering you prefaced it by saying you want to keep everything in flash.  so yes, given that requirement (ie, you want to put everything, if possible, in flash), put all your code inside flash.
    2) you need to scope everything. there's no problem (from flash/exportJS) spreading code over different frames/layers, if that's what you want to do.  you probably just need to be more careful with your scoping if think code in one layer won't recognize functions in another layer.  ie, in your top layer, use:
    var tl = this;
    // and then use tl to reference the main timeline in your functions (and elsewhere).

  • Executing code in form of String object

    hi to all,
    I don't know if it's the right place to ask such a question, but at least, I can try my chance :)
    Can I execute code originally written in a text area (JTextArea) (i.e. in form of a String object) as if it was code already embedded in the code flow ??

    There are several solutions.
    As suggested above use Runtime.exec() to compile it. You can do this either by having the user enter the entire class or by having the enter only a portion which you then wrap (they write a method, or some rules in a method, etc.)
    There is a VM/version specific interface that allows you to compile without Runtime.exec() . You can search the site for examples of this.
    You can also use one of the java embeddable languages if you just what 'code' rather than supporting the entire java language.....search the following page for "Scripting"...
    http://flp.cs.tu-berlin.de/~tolk/vmlanguages.html

  • Adf valueChangeListener autosubmit=true, execute code after update model

    Hello.
    I'm working with the valueChangeListener and autosubmit="true". I'll try to explain my situation
    with an example.
    jsp:
    <af:form>
         <af:panelForm>
              <af:inputText
                   id="value1"
                   label="Value1"
                   value="#{index.myObject.value1}"
                   autoSubmit="true"
                   valueChangeListener="#{index.changeListener1}"/>
              <af:inputText
                   id="value2"
                   label="Value2"
                   value="#{index.myObject.value2}"/>
         </af:panelForm>
    </af:form>
    backing:
    public class Index {
        private MyObject myObject;
        public Index() {
            myObject = new MyObject();
        public void changeListener1(ValueChangeEvent valueChangeEvent){
              doSomethingWithMyObject(myObject);
        // ... get/set of myObject
    MyObject:
    public class MyObject {
        private String value1;
        private String value2;
        public MyObject() {}
         //getters/setters...
    }In the line doSomethingWithMyObject(myObject) i need myObject with the actual values in the user form.
    in the example above, the first time the page is rendered and shows the inputs
    if the user captures something in the 1st input and then hits the tab to go to the other input
    the valueChangeEvent is fired, and the code in "index.changeListener1" executed, but at this moment
    the model (myObject) hasn't been updated with the data that the user entered (Validation Phase).
    So i need a way to execute my code called from the "valueChangeEvent" but after the model has been updated
    Some notes about my problem:
         - The doSomethingWithMyObject(myObject) could update data in myObject
         - About binding="#{x.y}":
         I know i can use the binding attribute in the tag <af:inputText binding="#{x.y}"> and then in the code of
         the changelistener the binded component always have the most recent value from the user,
         but i cant' use that, the method needs a MyObject instance.
         - I don't think create a new instance of MyObject and populate it every time the event fires is a good way
         - doSomethingWithMyObject" is a black box, so i don't know what is going to do with myObject
         - In my problem there are more than 2 inputs there will be N components M listeners.
    What I'm trying:
         PhaseListener:
         I have been implementing a solution with a PhaseListener like
         public void afterPhase(PhaseEvent phaseEvent) {
              // just after UPDATE_MODEL_VALUES phase
              FacesContext f = FacesContext.getCurrentInstance();
            Index i = (Index) f.getApplication().createValueBinding("#{index}").getValue(f);
              // at this point the model is updated
              doSomethingWithMyObject(i.getMyObject);
         public PhaseId getPhaseId() {
            return PhaseId.UPDATE_MODEL_VALUES;
              this works but i don't know if this is the answer according to this post (unanswered at this time):
              http://forums.oracle.com/forums/thread.jspa?threadID=611643
         says something about that PhaseListener is not thread safe and blocks the application with more
         than 1 user.
         A wrapper:
         using the controls binded to the backing
         public class Index {
              private MyObject myObject;
              private CoreInputText inputValue1;
              private CoreInputText inputValue2;
              //listener
              //getters/setters
         }     make a wraper like
         public class MyObjectW {
             private Index index; // wrap the backing index
             public MyObjectW(Index index) {
                 this.index = index;
             public String getValue1(){
                 return (String) index.getInputValue1().getValue();
             public String getValue2(){
                 return (String) index.getInputValue2().getValue();
             public void setValue1(Object v){
                 index.getInputValue1().setValue(v);
             public void setValue2(Object v){
                 index.getInputValue2().setValue(v);
        }and then call in the index backing:
    doSomethingWithMyObject( new MyObjectW(this)); so it will access to the most actual values from user at the valueChangeEvent
    But i really would like some way to execute my code called from the "valueChangeEvent" but after the model has been updated
    so i dont need to wrap or implement PhaseListener
    what do you think, what do you suggest, have any solution or a way to do what I'm trying?
    thank you for your help...
    Message was edited by:
    akanewsted

    Hello Frank, thanks for the response.
    When you say
    "If you need an updated object in this listener then you can update it from the value change listener as well"
    you mean i can update the object by myself with the value from getNewValue()? or is there another way
    to call to update the models at this time ?
    I know i have the methods "getOldValue()" and "getNewValue()" in the "ValueChangeEvent" but what if i need
    the actual value from the user in other control than the one that fires the event
    example
    Two inputs:
    in the input1 the user enters some data
    in the input2 when some data is entered it fires valueChangeListener (autosubmit=true)
    in that case what if i need the value the user just entered in the input1 in the valueChangeListener of
    the input2.
    In general the app I'm working must do:
    dynamically generate the controls in the form (inputs, selects etc)
    Attach the control values to a model ( <af:inputText value=#{model.x}"/>
    sometimes execute some script when a value change in a control (valueChangeListener)
    those scripts uses the model (and needs to be an updated model)
              script = " if (value2 = 'xyz') then value1='abc'; return true;";
    if the model is not updated
    the script will use old values and will be wrong
    or if the script change some value in the model, when the update model phase occurs the value from
    the script is lost.
    that's why i need to work directly with the model and not the values in the ValueChangeEvent
    Is there a way to use something like an action in the change of a control value?
    that way the code will execute in the invoke application phase, can this be done ?
    how i can execute code in the invoke application when a valueChangeEvent occurs ?
    hope this help to explain more my situation.
    Thank you for your help and time.

  • Java Comiler - How to find out the Number of lines of Executable code

    Hello,
    Is there any option we have or could have to get the "Number of Lines of Executable Code" while we run the java compiler?
    Technically Java is an interpreter. So in case the term is incorrect, please excuse me.
    Since the compiler anyway traverses through the Java files, it is easy and correct to get the number from the compiler rather than having any external tool calculating the same.
    It should remove the comments, blank lines and take care of java single sentence written in multiple lines.
    Any suggestions or help is highly appreciated.
    regards,
    Sabyasachi

    How many lines of code are there in this program?
    public class sabre20110211 {public static void main(String[] args) {for (int i = 0; i < 10; i++)System.out.println(i);}}And how many in this program?
    public
            class
            sabre20110211
        public
                static
                void
                main(
                String[]
                args
            for
                    (int i = 0;
            i < 10;
            i++
                System.out.println(i);
    }

  • Resource-only DLL does not contain executable code

    A resource-only DLL does not contain executable code. Since
    LoadLibrary (http://msdn.microsoft.com/en-us/library/windows/desktop/ms684175.aspx) attempts to call the entry point before returning, it will fail for resource-only DLLs. Instead, you should call
    LoadLibraryEx (http://msdn.microsoft.com/en-us/library/windows/desktop/ms684179.aspx) passing a
    LOAD_LIBRARY_AS_DATAFILE, LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE, or
    LOAD_LIBRARY_AS_IMAGE_RESOURCE flag, to load a resource-only DLL. This prevents to loader from attempting to call the entry point.

    Hello,
    Just check if there is space in the front of these numeric values or some garbage value...if there is... then it may not be able to pad it up with zero and hence the issue...check in R/3 about how these values are stored...you can remove the space from the front and change it in PSA...and then load but first do the analysis of the source system and see why its coming up wrong.
    Regards
    Ajeeet

  • Display the code but closed out of battery and I do not think I saw him get?

    Display the code but closed out of battery and I do not think I saw him get?

    reed code

  • Source Media Time Code in Export Frame Metadata

    It is possible to include source media time code in the XMP metadata for images created using the Export Frame command? When I export a frame, the metadata only contains sequence time code. I work for an aerial survey and remote sensing firm, and we use time of day time code from aerial video footage in many places in our workflow. We include still frames of key points in the video in our deliverables for clients, and the time code values we need come from the same points as those still frames, so our current workflow uses RedCine-X to export still frames and Digital PIE to extract source time code from those images. I would strongly prefer to work only in Premiere Pro and never open RedCine-X, but I can't keep the workflow all in Premiere Pro if I can't get source time code out with the images.

    That's a good suggestion Jim. I did try that before I posted, and exporting from the source monitor does embed time code in the XMP, but it's not time code I recognize. It's neither the media source time code nor the sequence time code where that frame appears in the only sequence I have in my test project. For example, I just exported a frame from the source monitor at 18:43:45:15 in the source media time code. That frame appears at 00:43:23:22 in the sequence I have open, and I used match frame to open the frame in the source monitor. The resulting time code in the XMP for the exported frame is 00:44:53:06. There are no options for anything except file name, format, and output directory in the Export Frame dialog, so I don't know how to control what time code Premiere sends out from the source monitor.

Maybe you are looking for

  • Extension Manager Crashes CS5 OSX 10.5.8

    Hi I need to load the Optional Plug Ins for Photoshop CS5 so Photoshop can use TWAIN to import images from my scanner. I've done it on another iMac but need to do it on this one. I have downloaded the files from the Adobe site and the Extension Manag

  • How do I stop apps from running in the background on my 4s

    How do I stop apps from running in background on my iPhone 4s?  I double tap the home button and the running apps will move right and left but no "x" appears to stop them from running.

  • Access ADSI through JNDI ?

    Hi All, Im a newbie to JNDI. Could you please answer to my following query: I wanted to access the ADSI (Microsoft's Active Directory Services Interface) with the client java code. I am aware that we can do this by using JNDI since a service provider

  • Video just show up as a black icon

    I just combined a couple of different Iphoto libraries onto my Imac and unfortunately all of the videos that I shot with my iphone or Flip just show up as black squares. Is there a way to change this? They still play but I can't tell what they are un

  • Error in automatic processing of output of a delivery

    Dear All, In the stock tranport scenario, I am using an output type SPED in an outbound delivery. When this is processed an inbound delivery is created automatically from the outbound. The problem is that the output is not being processed automatical