WindowClosing doesn't completely close a frame

I wrote a simple command line application that needs to prompt for a username and a password. Since the characters are always echoed in Java, the alternative way to do this is to call a GUI with a password-textfield. I am able to obtain the login credentials, and to dispose of the login pop-up window, but the program doesn't return unless I hit Ctrl+C.
Calling System.exit(0) does the job but not quite. I was hoping whether there is a way to completely destroy the Login GUI without having to warn the user of this class to call System.exit(0) each time the Login box is used. Most of the times the user doesn't even know that this class is called.
Is there any dispose, exit, close or whatever method that does this?
(It could be any of the classes: javax.swing.JDialog, java.awt.Frame etc.)

The goal is to totally get rid of the GUI threads still running on the background, not to just set the visibility to false. However, thanks to your code, with a couple of modifications, I figured out the solution.
I read the workaround in some other topic:
How to kill AWT-Windows thread - submitted on Dec 14, 2000.
If I set the window to null it does what I want.
Thanks!
import java.awt.*;
import java.awt.event.*;
public class temp {
public static void main(String args[]) {
ClosingWindow w = new ClosingWindow();
w = null;
class ClosingWindow extends Frame implements WindowListener {
public ClosingWindow() {
this.setTitle("temp frame");
this.add(new Label("Hit the close button!"));
this.addWindowListener(this);
this.setSize(400,200);
this.setVisible(true);
//Here are the event catchers
public void windowActivated(WindowEvent e) { }
public void windowClosed(WindowEvent e) { }
//This should clear up your window
public void windowClosing(WindowEvent e) {
setVisible(false);
dispose();
public void windowDeactivated(WindowEvent e) { }
public void windowDeiconified(WindowEvent e) { }
public void windowIconified(WindowEvent e) { }
public void windowOpened(WindowEvent e) { }

Similar Messages

  • Firefox doesn't completely close and an error message comes up

    It wasn't until this current version 10 of Firefox, did I start to experience an issue that seemed odd.
    Every time I close out of Firefox, I am assuming I'm completely out of it, but it's still running in the background. Shortly after I close Firefox (and it's still running hidden), I get an error message that pops up and it says:
    ''A script on this page may be busy, or it may have stopped responding. You can stop the script now, or you can continue to see if the script will complete.''
    ''Script: chrome://browser/content/sanitize.js:133
    At the bottom of this window it gives you two options: CONTINUE (and if you press that, Firefox stays hidden in the background, still running with plug in folders), or STOP SCRIPT (which, if you click on that, will shut down Firefox completely).
    So why is this occurring now as it is totally inconvenient and something that has not occurred with previous versions of Firefox?
    Thanks for listening....
    Ben Herrmann
    It does this on both of my computers.

    Hi,
    Please check if this happens in [https://support.mozilla.com/en-US/kb/Safe%20Mode Safe Mode.]
    [http://kb.mozillazine.org/Problematic_extensions Problematic Extensions]
    [https://support.mozilla.com/en-US/kb/Troubleshooting%20extensions%20and%20themes Troubleshooting Extensions and Themes]
    [http://support.mozilla.com/en-US/kb/Uninstalling+add-ons Uninstalling Add-ons]
    [http://kb.mozillazine.org/Uninstalling_toolbars Uninstalling Toolbars]

  • Could not complete the video frames to layers command because photoshop does not support video in th

    When I attempt to import a video I get the message "could not complete the video frames to layers command because photoshop does not support video in this version of windows"  I am running on windows 8.1 pro (32 bit), shouldn't this be compatible???????????

    Unfortunatly, the 32 bit versions of windows doesn't support video in photoshop cc.
    see this post:
    http://forums.adobe.com/message/5802978#5802978

  • Close a fram

    i want to close a frame after i click a button... i have the button setup and added an action listener to it then i perform the functions i need performed but after everything is done i would like to exit or close the entire frame... how can i do that?

    <implement beatnik>
    uh... OP question I am assuming has to do with :
    myFrame.setVisible(false);//hides frame
    myFrame.dispose();//prepares frame for disposal - doesn't actually dispose as you could call setVisible()
    myFrame = null;//kill your reference.
    System.gc();//cross your fingers and hope like hell that the GarbageCollecter gets the message... all better ?
    :)

  • Close a frame

    Hi.
    Instead of exit the application at the line System.exit(0); I just want to close the frame or hide it.
    I have tryed with the lines that are commented, but it didn't work.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class PaginaPrincipala extends JPanel implements ActionListener {                               
        private static String EXIT = "exit";
        private JFrame controllingFrame;
            public static String user;
            JPanel panel;
            //JFrame f;
        public static void FereastraPrincipala(String inUser) {
             user = inUser;
            JFrame.setDefaultLookAndFeelDecorated(true);
            JFrame frame = new JFrame("PaginaPrincipala");       
            frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
            final PaginaPrincipala newContentPane = new PaginaPrincipala();
            newContentPane.setOpaque(true);
            frame.setContentPane(newContentPane);
            newContentPane.ContinutPaginaPrincipala(frame);
            frame.addWindowListener(new WindowAdapter() {
                public void windowActivated(WindowEvent e) {
                    newContentPane.resetFocus();
            frame.pack();
            frame.setExtendedState(frame.MAXIMIZED_BOTH);
            frame.setVisible(true);
            frame.toFront();       
            //f = frame;    
        public void ContinutPaginaPrincipala(JFrame f) {
             panel = new JPanel();         
             GridLayout layout = new GridLayout(5, 2, 5, 5);
              panel.setLayout(layout);
              JTextField campTempUser = new JTextField(20);
              JButton butonExit = new JButton("Exit");
            butonExit.setActionCommand(EXIT);
            butonExit.addActionListener(this);
              add(panel);
              panel.add(butonExit);                          
        public void actionPerformed(ActionEvent e) {
            String cmd = e.getActionCommand(); 
            if (LOGIN.equals(cmd)) {              
            if (EXIT.equals(cmd)) {
                 InregistrareLaInchidereaAplicatiei inregistrareLaInchidereaAplicatiei = new InregistrareLaInchidereaAplicatiei();
                inregistrareLaInchidereaAplicatiei.InregistrareInDB(user);
                 System.exit(0);     
              //frame.setVisible(false);
    }

    "And if he still doesn't answer ?"
    Yes, I have tried, but it still doesn't work. And I feel that it must be so simple.
    When I click the Exit button, the frame must disappear.
    Here is the code with the main function:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class PaginaPrincipala extends JPanel implements ActionListener {
        private static String EXIT = "exit";
        private JFrame controllingFrame; //este nevoie pt dialoguri.
            public static String user;
            JPanel panel;
            JFrame f;
       public void FereastraPrincipala() {
             //user = inUser;
            //setari pt grafica ferestrei.
            JFrame.setDefaultLookAndFeelDecorated(true);
            //creeaza si seteaza fereastra.
            JFrame frame = new JFrame("PaginaPrincipala");      
            frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
            //creeaza si seteaza 'content pane'.
            final PaginaPrincipala newContentPane = new PaginaPrincipala();
            newContentPane.setOpaque(true);
            frame.setContentPane(newContentPane);
            newContentPane.ContinutPaginaPrincipala(frame);
            //seteaza focusul pe 'content pane'.
            frame.addWindowListener(new WindowAdapter() {
                public void windowActivated(WindowEvent e) {
                    newContentPane.resetFocus();
            //Afiseaza fereastra.
            frame.pack();
            frame.setExtendedState(frame.MAXIMIZED_BOTH);
            frame.setVisible(true);
            frame.toFront();      
            f = frame;
        public void ContinutPaginaPrincipala(JFrame f) {
             panel = new JPanel();         
             GridLayout layout = new GridLayout(5, 2, 5, 5);
              panel.setLayout(layout);
              JTextField campTempUser = new JTextField(20);
            //Butonul 'EXIT'
            JButton butonExit = new JButton("Exit");
            butonExit.setActionCommand(EXIT);
            butonExit.addActionListener(this);
              add(panel);
              panel.add(butonExit);                          
        public void actionPerformed(ActionEvent e) {
            String cmd = e.getActionCommand();       
            //daca se apasa EXIT se sterge userul din DB-ul cu userii activi si se iese din aplicatie
            if (EXIT.equals(cmd)) {
                 //System.exit(0);
                 Toolkit.getDefaultToolkit().beep();     
                 f.setVisible(false);
        public static void main(String args[]) {
             PaginaPrincipala fer = new PaginaPrincipala();
             fer.FereastraPrincipala();
        //Muta focusul pe campul de user.
        protected void resetFocus() {
            //campLogin.requestFocusInWindow();
    }

  • Error message "could not complete the video frames to layers command because dynamiclink is not avai

    So I decided to try my hand at making gifs and so I attempted to upload a video by going to file -> import -> video frames to layers. Before even letting my pick my video it comes up with an error message saying "could not complete the video frames to layers command because dynamiclink is not availible." I then tried file -> open -> and then selected the video and no matter what file type or size I chose I ended up with the same error message.
    I looked this problem up and attempted some of the solutions but to no avail. I tried clearing my preferences and restarting photoshop many times in addition to restarting my computer. I also checked to make sure it wasn't being blocked by any firewalls and it wasn't. My opperating system is Windows 7 and I'm using photoshop cs6. I've looked everywhere for an answer to this problem so if anyone is able to help me solve this problem I'd be much obliged.

    You see my C:\ drive is quite small as it's a SSD, so I made Adobe install programs on my E:\ drive too, however this was the main cause for Adobe not to function.
    After adjusting the settings to install everything back to my C:\ drive, it fixed my issue above and allowed me to run the 64bit version.

  • Mobile account doesn't complete initial creation and sync process

    I'm trying to setup a mobile account for a network account but it won't complete the sync process on the client MacBook Pro. Both the server and the MacBook Pro are running 10.5.5.
    When I login to client it prompts me to create a Mobile account and proceeds with the sync to create the account, but when the sync is complete it just logs in with the default account setup. None of the user files or settings (desktop image, preferences, etc) appear. The sync process says "Checking..." for all the files that supposedly get copied to the client, but it looks like it doesn't complete.
    Is there a way of knowing what the problem is? Is there an issue with the user's home directory, some file that prevents the sync and mobile home creation from completing?
    Thanks.

    I solved this myself. The user ended up have a folder on his desktop that contained a backup home folder from an old powerbook that he was trying to save. It was a complete home folder, Documents, Library, etc and I thought it might be interfering with the sync of the normal home folder. So I created a folder called Bad Stuff in the home folder and copied the old powerbook home folder into it. Then opened up the Sync Settings and excluded the Bad Stuff folder from the sync. And it worked, the sync when fine and is resyncing fine.
    Hope that helps with other people with a similar problem.

  • Could not complete the video frames to layers because of a program error

    Whenever I try to import video into frames to layers on photoshop, I get this error. (could not complete the video frames to layers because of a program error)
    Why is that and how do I fix it???

    You see my C:\ drive is quite small as it's a SSD, so I made Adobe install programs on my E:\ drive too, however this was the main cause for Adobe not to function.
    After adjusting the settings to install everything back to my C:\ drive, it fixed my issue above and allowed me to run the 64bit version.

  • "Could not complete the Video Frames to Layers command because the movie file could not be opened."

    I'm using Photoshop CS5 extended.
    I've been using that to make gifs. It was fine when I import video frams into layers with the video formats of .mov or .avi. But After I installed OSX 10.6.8, this message comes up everytime I want to import videos: "Could not complete the Video Frames to Layers command because the movie file could not be opened."
    So I installed my old OS back which is 10.6.3 but the problem is still there.
    May I know what to do to solve this problem because all along I've been fine with making gifs and importing videos until now.
    Please help, thank you.

    Adnicej- wrote:
     ...I've been using that to make gifs...
    The computer deities may be trying to say something to you.  GIF is not a video format.
    Are you opening video with the same codec that was successfully opened before?

  • Could not complete the video frames to layers command because the file could not be opened

    I recently learned to make gif images using KMPlayer and my Photoshop CS6, but today I hit a snag that I can't seem to get around. Normally I capture a scene from a show DVD I have in KMPlayer and then import the video frames into layers/frames in photoshop with no problem. Well today I went to do that, and captured the scene with what seemed like no problem (the small captured scene saved with no problem) but when I went to CS6 to import the video into layers, I got the error message "Could not complete the video frames to layers command because the file could not be opened". At first I thought it was the KMPlayer saving the files wrong, so I retried and got the same error message. Irestored the players settings back to a default and the file still wouldn't open in photoshop, and then I even tried uninstalling/reinstalling the player trying to get it to work, and then I thought it must be photoshop, because even scenes I had captured at an earlier day that worked perfectly fine when importing would not open.
    What could possibly be causing this problem to occur. Should I uninstall/reinstall photoshop and see if that works, or am I doing something wrong?
    The files I'm trying to import are AVIs as always, I even tried to capture scenes in other formats to no avail. What could be causing the problem?

    I uninstalled an reinstalled photoshop totally and it didn't fix the problem either. I made a post on the KMPlayer's forum hoping for an answer but I haven't recieved one yet. I'm starting to think it's the kmplayer having a problem capturing, since I've started getting the error "could not import the file to layers because the file has no layers" sometimes in photoshop, but I'm still trying to work around in photoshop to see if the problem came from there.

  • Could not complete the video frames to layers command because the DynamicLink Media Server is not av

    I have this problem, I have PS CS6 and when I click on File> Import> Video Frames to Layers.. Next, the window that says "Initializing Video Import" starting to load and always get stuck and that's what appears: "Could not complete the video frames to layers command because the DynamicLink Media Server is not available". That's with aaaall the videos.
    PS: I've been trying with File> Open but that's what says "Could not complete your request because it is not the right kind of document"
    Anybody know what happens to my photoshop? Thx!

    The relevant auxiliary service/ helper app is being blocked and thus not launching,. anything from permissions issues to security tools getting in teh way. Check your Task Manager/ Activity Monitor, turn off security stuff, run as admin.
    Mylenium

  • I tried restoring my iMac 27" slim. I followed the steps erased my data then to reinstall osx mavericks. Now that I'm trying to reinstall osx mavericks for whatever reason it doesn't completes. Can you help me out?

    I tried restoring my iMac 27" slim. I followed the steps erased my data then to reinstall osx mavericks. Now that I'm trying to reinstall osx mavericks for whatever reason it doesn't completes. Can you help me out?

    That's not quite the proper way as far as I can tell. Usually, one boots directly into the Recovery HD using COMMAND and R keys at startup. If you cannot do that then most likely there is a problem with the hard drive. Since this is a new computer i would make a Genius Appointment and take it in for service.

  • I have a problem with Farmville on facebook,the game doesn't fit in its frame (I don't have this prblem when using Linux) so I can't game properly

    I have a problem with the game Farmville on facebook.
    When I go to the game ,the game doesn't fit in the frame (of Adobe flasplayer) ,so I can't game properly ,because features fall outside the frame.
    I don't have this problem when I game on a notebook with Linux,there ,the game fits the frame exactly,so the problem is not with Adobe flashplayer,but with Windos 7 in combination with Firefox?

    Reset the page zoom on pages that cause problems: <b>View > Zoom > Reset</b> (Ctrl+0 (zero); Cmd+0 on Mac)
    * http://kb.mozillazine.org/Zoom_text_of_web_pages

  • When I Load a Movie or New Movie it doesn't completely Load

    When I Load a Movie or New Movie it doesn't completely Load. So When I click the iMovie HD Icon on My little Bar thing. The screen comes up and the blue bar Only Goes to the Middle and stops. It says to wait a few minutes, But I have waited 7 hours and more everyday. Please Help. I Love to make Movies, and I'd hate for my passion to Stop.
    Mac OS X   Mac OS X (10.4.9)   iMovie HD 6

    Hi Mandi
    Two thoughts. Your Mac is struggeling about how to get organized.
    - free space on internal hard disk should read more than 10Gb and even
    rather like 25GB
    - The hard disk that You store Your movie on can be in wrong format
    ∆ is it formatted OK (if only one = internal it's most probably OK)
    ∆ external hard disks MUST BE - Mac OS Extended formatted to work
    • DOS/UNIX/Mac Exchange - won't do !
    - The hard disk can be untidy:
    ∆ Run: Repair Permissions (Apple Disk Util tool)
    ∆ Run: Repair Hard disk (Apple Disk Util tool) (You need to start from CD/DVD
    or externa hard disk)
    ∆ AND - delete iMovie pref file (or start a new account / log into this and re-try.
    (will do the same but it discards even more eventually faulty files)
    Yours Bengt W

  • My restore takes 12hrs and doesn't complete, after 6.0.1

    iOS 6.0.1 upgrade reset my phone to factory settings. Now my restore takes 12hrs and doesn't complete, I have tried this twice, please help.

    The Basic Troubleshooting Steps are:
    Restart... Reset... Restore...
    iPhone Reset
    http://support.apple.com/kb/ht1430
    Try this First... You will Not Lose Any Data...
    Turn the Phone Off... ( if it isn’t already )
    Press and Hold the Sleep/Wake Button and the Home Button at the Same Time...
    Wait for the Apple logo to Appear and then Disappear...
    Usually takes about 15 - 20 Seconds... (But can take Longer...)
    Release the Buttons...
    Turn the Phone On...

Maybe you are looking for