Action when JFrame is closed

Ok, i want to perform some action (defined in function close() ) when the user closes a JFrame. Its not happening for me, though...
frame.addWindowListener(new WindowAdapter(){
        public void WindowClosing(WindowEvent e){
             close();
});WindowClosed(WindowEvent e) aint working either.
While im here, i have another question thats is bugging me:
How come things like
Image img=jpanel.createImage(600,400);
Graphics g=img.getGraphics();Often return null?

Encephalopathic wrote:
prolly need to use @Override to prevent this from biting your again.
and we're 100+ in NC. I'm sitting here as they work on the broken air conditioning unit.Meanwhile, out west: [snow at elevations...|http://www.theweathernetwork.com/index.php?product=weather_cams&placecode=cabc0149&pagecontent=weather_cams&camregion=canada&camera=CMBC0030]

Similar Messages

  • Why my system tray application terminates when JFrame is closed???

    Hi,
    I am using JDK 1.6 with Netbeans 5.5 and currently trying to make an system tray application. I have one main class which runs as a system tray application and one JFrame class which will be shown when user selects a menu item from system tray. So far so good but a small problem. When the JFrame form is closed, my system tray application also closes. Can somebody tell me what am I missing?
    Thanks

    set the DefaultCloseOperation of the JFrame to DISPOSE_ON_CLOSE instead of EXIT_ON_CLOSE
    db

  • Execute instructions when JFrame is closing

    Hi,
    I have a JFrame and I want to save some information (using java.util.prefs) when the user closes it.
    How Do I execute some instructions when an user closes a JFrame?
    Thank's!

    You could write a window listener: http://java.sun.com/docs/books/tutorial/uiswing/events/windowlistener.html
    Or use a shutdown hook: http://java.sun.com/javase/6/docs/api/java/lang/Runtime.html#addShutdownHook(java.lang.Thread)
    I think the window listener usually makes more sense.

  • How to preven JButton of generated actions when the user keep pressing down

    How to preven JButton of generated actions when the user keep pressing down the key or the short cut
    The code below to show the issue when the user keep pressing Alt+ O
    We want to prevent the JButton from generating multi actions just one action only
    A sample of code shows the behaviour which has to be prevented. Continue pressing "Alt +O" and you will see the standard ouptput will print time stamps
    Please notice, I am NOT interested in Mouse press which has a solution by adding a threshold ( setMultiClickThreshhold(long threshhold) on the JButton  as an attribute.
    public class TestPanel extends JPanel
       private JButton btn;
       public TestPanel()
          btn = new JButton("Open");
          this.add(btn);
          registerCommand(new MyAction(), InputEvent.ALT_MASK,
                KeyEvent.VK_O, btn, btn.getText(), 0);
       public static void registerCommand(AbstractAction action,
             int mask,
             int shortCommand,
             JComponent component,
             String actionName,
             int mnemonicIndex)
          InputMap inputMap = component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
          KeyStroke knappKombination = KeyStroke.getKeyStroke(shortCommand, mask);
          if ((component instanceof AbstractButton)
                && mnemonicIndex >= 0
                && mnemonicIndex < actionName.length()
                && (shortCommand >= KeyEvent.VK_A && shortCommand <= KeyEvent.VK_Z))
             ((AbstractButton) component).setDisplayedMnemonicIndex(mnemonicIndex);
          if (inputMap != null)
             ActionMap actionMap = component.getActionMap();
             inputMap.put(knappKombination, actionName);
             if (actionMap != null)
                actionMap.put(actionName, action);
       public static class MyAction extends AbstractAction
          private static final long serialVersionUID = 1L;
          @Override
          public void actionPerformed(ActionEvent e)
             System.out.println(System.currentTimeMillis());
       public static void main(String... args)
          SwingUtilities.invokeLater(new Runnable()
             public void run()
                JFrame frame = new JFrame("Testing");
                JPanel panel = new TestPanel();
                frame.getContentPane().add(panel);
                frame.setPreferredSize(new Dimension(500, 500));
                frame.setMinimumSize(new Dimension(500, 500));
                frame.pack();
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setVisible(true);
    }Edited by: user12130673 on 2013-feb-13 03:01

    Use KeyStroke getKeyStroke(int keyCode, int modifiers, boolean onKeyRelease) with onKeyRelease=true instead?

  • SVG filters disappearing from Actions whenever Illustrator is closed

    Hi all.
    I'm working on a file I'd like to use as a template, and it will include some actions.
    Here's the problem - once Illustrator has been closed and reopened, while the custom actions still show up, they no longer contain the SVG filters. It requires the user to reload the set of actions every time they reopen Illustrator.
    Part of the point of the template is to reduce the extra steps in workflows, so I'm hoping someone can suggest a way to fix this.
    Discussed it with other designers on my team, and they suggested we include the actions in the Presets folder, hoping it would automatically do some sort of "fresh install" of the actions when we load Illustrator. We tried that - I actually added the actions into the default set, and though it loads the actions, they still show as having lost the filters. Again, the only way to get them back is to reload the actions separately.
    Any ideas?
    Thanks!

    I'm not familiar with ExtendScript, but the filters I am using are VERY simple - do their default filters include ExtendScript...? (seems unlikely, but then again, clueless about ExtendScript).
    Here's one I am using:
    <filter  width="200%" height="200%" id="AI_GlowBlur" y="-50%" x="-50%">
              <feGaussianBlur  stdDeviation="5"></feGaussianBlur>
    </filter>
    Could it have anything to do with the fact that they are inserted from the menu? Although like I said, the actions work fine until Illustrator is closed and reopened. :-( So probably not.
    Ugh.

  • Is there a way to auto sign out from itunes store when itunes is closed?

    We have multiple libraries on one PC (Win7). Each user has their own Itunes account and their own Itunes library. When Itunes is closed and then reopened into a different library, the Itunes Store remaines signed in to the last user who signed in. I would like to automatically sign out of the Itunes store when Itunes is closed. Anybody have a suggestion?

    Hi,
    iChat and Messages 7 (Mountain Lion) had a pane in the App Menu > Preferences  called Alerts.
    This could see the Sounds in iChat (or Messages), the System Sounds defaults and anything you had stored in ~/Library/Messages and you could set any of these Sounds to any of the 17 actions as a global choice
    As in Maverick if you highlight a Buddy in a Buddy List and then use CMD + i (Get Info) you could similarly set sound to individual Buddies.
    You cannot do this in Mavericks/Messages 8 as the Alerts Pane have disappeared.
    You cannot turn Off the sounds the app makes for the various different actions such as Video Invite or File Transfers.
    You can no longer set individual Buddy sounds either.
    There has not been a way to do this for iMessage Contacts.
    9:28 pm      Sunday; December 8, 2013
      iMac 2.5Ghz 5i 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

  • Why does captivate hang when it is closed in window 8.1 professional ? How is it solved?

    Why does captivate hang when it is closed in window 8.1 professional ? How is it solved?

    Hi,
    Do you see the issue every time you close captivate or is it only in some scenarios? Does it show any error messages? What captivate version are you using (64 bit or 32 bit)? Can you provide some more information or screenshots which can help us reproduce the issue.
    Tamish

  • How to call an action when the user selects a radiobutton

    Hai
    PLease help me in providing the information.
    In my Project i have two radio buttons as
    New
    Asssessment
    when the user selects new button, i want to automatically call an action in the controller(.jpf file)
    Simalarly when he selects the other radio button i need to call a separate action in the controller.
    Remember i dont have the submit button.
    I want to dynamically call an action when the user selects the radio button.
    i dont have any field inthe radio button which actually takes action as an attribute .
    please provide me the necessary

    Hi,
    You can use JavaScript to call the action in interest upon the Radio Button Element Being Selected.Should be simple, and if your controller is part of the portlet dont forget to use the jpfScopeId to asscoiate the controller instance with the one in the portlet.
    Let me know if you have any further questions.

  • I cannot delete cookies after updating to 9.0.1, also when opened, I have 2 new cookie files that disappear when FF is closed.

    I have uninstalled/reinstalled 9.0.1, the same thing happens. Checked my Profile, cookies.sqlite is there when FF is closed or uninstalled. When installed and opened, I have 2 new files, cookies.sqlite-wal and cookies.sqlite-shm, along with cookies.sqlite. Is this the reason I can't delete cookies? Also I have, and have had enabled AdBlock Plus and Privacy Browsing. After updating, I can't post anything to FF Support (this is my 4th attempt, finally used Safari to post) and files under Tools, such as Clear History are accessible, I shouldn't have a History to delete.
    (1st edit)
    OK. I reinstalled FF 9.0.1 from Safari, but not directly from Mozilla. I used CNet, now things are working like they should. I have no cookies listed, except the ones I want. Private Browsing is working properly. However, I still have those 2 extra cookie files; -wal and -shm.
    (2nd edit)
    I spoke too soon. After accessing sites that I frequent, the 'ad' cookies are back (adbright, realmedia, 247realmedia) and the site cookies are eliminated, not there, gone. Now I can't login to anything and am back to Safari to access FF Support Forum. Do I have a bug? Someone please help, I'm desperate, I hate IE, Safari, Chrome, etc. They have neither the level of ad and pop-up elimination that Firefox has; nor, do they have the level of customization that Firefox has. The 2 extra cookie files, -wal and -shm, are still there when FF is open, and gone again when FF is closed. One more thing I noticed, I have a Chrome Support Application file in my Library. Could the Chrome cookie file interfere with FF cookies? I wouldn't think so, I have Safari, as well, and neither browser has ever interfaced with the other before.
    (3rd edit)
    I have uninstalled/reinstalled FF, all of my add-ons and also tried deleting the cookies.sqlite document from the FF Profile file, to no avail. I have counted, there are 14 sites listed in the Preferences>Privacy>Show Cookies pane (no pun intended) and they are all "ad" sites. These sites are also listed as blocked sites in Adblock Plus. Until someone answers, I give up, I don't know what else to do. There was only the one time that the cookies were gone from the Show Cookies pane, every other time I uninstalled/reinstalled anything, they were still there. So, until someone helps me, I'm stuck. The only thing I have not done is deleted the Profile file altogether. That is the last thing I want to do, unless I can save my bookmarks somewhere to move back after reinstallation. If this isn't rectified within a few days, I may just try that, too.

    Do you have an extension like TACO (Abine) or TrackerBlock that maintains a set of OPT-OUT cookies?
    * Targeted Advertising Cookie Opt-Out (TACO): https://addons.mozilla.org/firefox/addon/targeted-advertising-cookie-op/
    * TrackerBlock: https://addons.mozilla.org/firefox/addon/trackerblock/
    * Beef Taco (Targeted Advertising Cookie Opt-Out): https://addons.mozilla.org/firefox/addon/beef-taco-targeted-advertising/
    If you do then you need to disable or uninstall such an extension.
    If clearing the cookies doesn't help then it is possible that the file <i>cookies.sqlite</i> that stores the cookies is corrupted.<br />
    Rename (or delete) <b>cookies.sqlite</b> (cookies.sqlite.old) and delete other present cookie files like <b>cookies.sqlite-journal</b> in the Firefox Profile Folder in case the file cookies.sqlite got corrupted.
    *http://kb.mozillazine.org/Cookies

  • My opening page won't load the home page even though I set it to home page in preferences.  Instead it always opens to the last page I had when I last closed.  I'd like it to open to my home page.  I've tried dumping and reloading Safari, I have 5.1.2.

    My Safari 5.1.2 Just won't open to my home page even though I have it set in preferences.  It continues to open on the last page I was on when I last closed Safari.  What overrides my settings in preferences?

    I just purchased my first MAC after working on PC for the past 25 years and would like to know how to keep my safari program to be the full screen everytime I get into the app. I always have to click the two arrows to the top right of the safari program but on a PC it is always opened in full screen mode ??? and while I have you plugged in how do you make it so that the manu bar does not go away (hyernate??)
    Cheers

  • How can I get my MacBook to stay on and not sleep when lid is closed?

    How can I get my MacBook to stay on and not sleep when lid is closed?

    try this: http://www.macupdate.com/app/mac/37991/nosleep

  • My Photoshop CS 5 has some strange actions when I copy a portion of a photo using the clone stamp  to transfer to another part of the image. It carries the entire layer (not just the stamps selection) across the screen and I cannot place it where I need t

    My Photoshop CS 5 has some strange actions when I copy a portion of a photo using the clone stamp  to transfer to another part of the image. It carries the entire layer (not just the stamps selection) across the screen and I cannot place it where I need to. It appears as if I selected the entire layer on purpose (which I did not)
    The below items appeared when I opened Photoshop CS 5:
    “Photoshop has encountered a problem with the display driver and has temporarily disabled G & U enhancements. Check the video card malfunctions website for latest software. GPU enhancements can be enabled in the performance panel of preferences.”
    (I believe this started after the automatically updated Windows was applied. It was coincident with the before mentioned problem . . . but I don’t really know if it had anything to do with it. )

    For the Clone Stamp problem, check the Clone Source panel and Clipped is probably unchecked.
    If so, check Clipped and see if that makes a difference.
    (Window>Clone Source)
    As to the video card problem:
    Which version of windows are you using?
    What is the make and model of your graphics card?
    Do you know which update windows installed?

  • TS1363 Ipod does not appear in my computer or recognized in itunes. When ipod is connected a window pos up aking to import photos off the device and when this is closed the ipod cannot be recognized. Any Help?

    Ipod does not appear in my computer or recognized in itunes. When ipod is connected a window pos up aking to import photos off the device and when this is closed the ipod cannot be recognized. Any Help?

    Which OS are you using? 
    In the meantime, research your problem in Knowledge Base. 

  • Why viber is not working when i am closing the app?

    in my iphone 4 mobile i am facing a problem. when i am closing my apps i am not getting any calls. when i am opening the apps then i am getting calls, sms and miscalls. I am connected with wifi. in this same connection others users are getting calls when they are closing the app. what is my problem? i have uninstalled the app and again i have installed it. but problem remains same. Anyone is not getting me!!!! Please reply as soon as possible.

    Try the stamdard fixes to rule out a software problem:
    - Reset. Nothing will be lost
    Reset iPod touch:  Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Restore from backup
    - Restore to factory defaults/new iPod.

  • When I try to download Adobe Flash Player, it says I need to quit out of Safari even when it's closed. How do I fix this?

    When I try to download Adobe Flash Player, it says I need to quit out of Safari even when it's closed. How do I fix this?

    Apologies for the slightly pedantic answer, but in application terms, "closed" and "quit" are two different things. An application such as Safari can have several windows open, and each of them can be closed using the red button in the corner.
    However, even after all windows are closed, the application is still running until you specifically quit it. You can tell it's still running by the small light under its icon in the Dock. If you hold your cursor down on the icon for a few seconds, you should see a pop up menu with the "Quit" option - click that to quit it. Or, click the icon once (this may launch a new window), then either go to the Safari menu and click Quit, or click cmd-Q, to completely quit the app.
    Matt

Maybe you are looking for

  • Tomcat 404 error while running jsp

    Hi all, I am trying to deploy a project on our intranet server. But when i give the url on the browser it gives the error " HTTP ERROR 404 resourse not available" It is not able to find the location o the index page. Rest other projects which are alr

  • Anyone having problems re-installing itunes 9.3 after uninstalling 10.1 version

    I have Windows XP Vista 32, and had problem with Applesyncnotifier not found error msg. The message suggested I uninstall the itunes version I had (10.1) and re-install, which I attempted to do. However, since I have Windows Vista Win32 bit, the 10.1

  • Debugging a Background job

    Hi everybody,            what are the different wasy to debug a job which is assigned in background. Can we debug a back ground which is running, or we can only debug the completed jobs. thanks in advance,          santosh.

  • Bdc messages in spool

    Hi all, I am using call transaction to run a bdc. here all the messages whether success/error are displayed as type "S". so its difficult to capture error messages. It executes fine in foreground and all the errors are displayed on the top of page bu

  • Fragmented free space in empty LMT ASSM tablespace?

    select count(*) from dba_extents where file_id=127;COUNT(*) 0 select count(*) from dba_free_space where file_id=127;COUNT(*) 2 select block_id, blocks from dba_free_space where file_id=127;   BLOCK_ID     BLOCKS        128     507904     508032     1