JFrame close all windows and send to front

2 JFrame questions:
1. Is there a way to keep JFrames above all other windows? For example, if a frame was on the screen and Internet Explorer opened, the frame would stay on top of the Internet Explorer window and would still be on the screen.
2. is there a command to close all JFrames? I have a loop that creates a new frame each time it runs. How can I say close all Boxes when the exit choice is selected?
if (x = 1)
JFrame frame = new JFrame ();
Box.getContentPane ().add (new JLabel (new ImageIcon (Toolkit.getDefaultToolkit ().getImage ("Image1.gif")))); Box.setUndecorated (true);
Box.pack (); //prepares the image
Box.setLocation (NextPlace, 0);
NextPlace = NextPlace + 17;
Box.setVisible (true);
}

I figured it out:
System.exit (0);
anyway thanks for your help.
what about the other question?
does anyone know if there is a send to front command
so that the JFrame is above all the other windows?System.exit(0); will close the program. But if you just want to close windows this won't work.
Instead you can use this:
int iterator;
     Frame[] frame = JFrame.getFrames();
          for(iterator = 0; iterator < frame.length; iterator++){
                    frame[iterator].dispose();
This will get all windows and close them.
Also you must add this: import java.awt.Frame;

Similar Messages

  • Once I close all windows and try to open another I get a message saying"Firefox is still running, you must close all browers before opening a new window. Why is this happening? I have the 3.5.10 Version

    I close all Firefox windows. When I try to open another window later I get a message telling me that Firefox is still running and that I need to close all windows or restart my computer. I have this about 3 times a day this past week but prior to that it was maybe every one or 2 weeks. I had the 3.5.10 Version of Firefox, but have just updated to see if this stops this from happening. But what do I do if it doesn't stop it?

    There are a few possible causes for that error, for details see [[Firefox is already running but is not responding]]

  • After closing all windows and trying to open a new window I get a message saying Fire Fox is running in another open window

    When I close all windows and try to reopen fire fox I get a message that fire fox is already running in another window and needs to be closed to restart.

    There are a few possible causes for that error, for details see [[Firefox is already running but is not responding]]

  • Cannot get "Quit and Close All Windows" to work

    Each time I open any application on my Mac, it automatically opens any other windows for that app that I had previously left open and unsaved (including ones I had temporarily opened to view a file, which remain titled "Untitled", etc.)....I've tried UN-checking in the General area of System Preferences "Restore windows when quitting and re-opening apps", but this does ABSOLUTELY NOTHING. I've ALSO tried holding the Option key down while choosing Quit in a given application such that the "Quit" command changes temporarily to "Quite and Close All Windows", but, again, when I re-open the application, it re-opens all the previously left open windows as well...
    I've found this behavior in programs such as Preview, Mail, Safari - the list goes on. What gives :-)? Thanks for any help!
    Sincerely.
    D.D. J.
    Mac Pro (early 2009), 32 gigs RAM running Lion 10.7.4

    Thansk for the quit reply! However, I'm afraid there are still problems:
    It the Resume feature.
    When choosing Restart, Sleep or Shutdown there is a checkbox you can uncheck to prevent the apps from launching.
    This is actually the only time my windows DO fully close, when I uncheck the re-open previous apps after doing a cold-restart of my entire Mac (not exactly practical when all I want to do is not have to manually close a zillion windows that have inexplicably re-opened upon re-opening a given application like Mail...
    Also in System Preferences > General there is a hard-to-find checkbox under "Number of recent items" you can turn off.
    Also, you can hold the shift key to disable resume on a one time basis.
    I've tried setting the "no. of recent items" all to 0, and this has no effect. I've also (as I mentioned before) DE-selecting "Restore windows when quitting and re-opening apps", which also has no effect (this is particularly perplexing, since this seems like the most logical way to enable what I'm seeking). I've similarly also tried option-Quitting from within the app to no avail...
    Again, you can accomplish this through Finder by going to ~/Library/Saved Application State and deleting the folder.
    I thought this would be the ultimate solution - just delete the entire "Saved Application State" folder, as you suggest. However, I tried this (temporarily changing it's name to "Saved Application StateOLD"), but when I closed Mail (with opened windows) and then re-opened it, not only did the windows still re-appear, but a NEW "Saved Application State" folder was created, saving presumably the new Resume data for seemingly this and any other apps that I still had open on my computer.
    If you want to turn it off on a per app basis, (TextEdit is by example, replace TextEdit with the name of the app)
    Launch Terminal and copy/paste this at the prompt...
    defaults write com.apple.TextEdit NSQuitAlwaysKeepsWindows -bool false
    Press return.
    To turn off Resume globally...
    chflags uchg ~/Library/"Saved Application State"
    Press return
    If you're CERTAIN the above won't mess up my computer :-) I guess I'll try this next, either App by App, or Globally. However, please confirm that you're saying that to delete Resume globally, I need to enter the chflags info (above), word-for-word, into Terminal?
    Thanks again -
    DDJ

  • (Mountain Lion) suddenly the screen turns black, and I have to use the switch to turn it on. And, the screen turns to zoom, and the only way to turn to normal is to close the window and start all over again?

    (Mountain Lion) suddenly the screen turns black, and I have to use the on/off switch to turn it on. And, the screen turns to zoom, and the only way to return to normal is to close the window and start all over again?

    Does the screen go black while you are using the machine? ...or after it has sat idle for a bit?
    If it happens while you're using the machine, check to see if a hot corner has been set for sleep. You can do that here: System Preferences > Desktop & Screen Saver > Screen Saver and click the button labelled "Hot Corners..." in the lower right.
    If it happens after a bit of idle time, that's normal sleep behavior. The delay can be adjusyed here: System Preferences > Energy Saver.
    In either case, pressing any key on the keyboard should bring it out of sleep.
    Re zooming -
    If this happens while in Safari, and you are using an Apple Magic Mouse, a default setting applicable to it is that a soft double-tap on the mouse will zoom the Safari window. A second double-tap will bring it back.
    If it is the entire screen that is zooming, Control plus scroll gesture on the mouse will zoom the whole screen. Repeat with the opposite scroll gesture to bring it back.

  • How do I open with one click all the windows that I have been minimized? When I right click on the lower bar Firefox icon, I only see the option to close all windows.

    It is used to be that I could right click on the Firefox icon on the toolbar at the bottom of the screen and I would then be given the option to open all windows. Now I only see the option to close all windows. The ability to open all windows is very useful. Have you eliminated this capability? It was a very helpful feature because I often have more than 15 windows minimized at one time. On a regular basis I like to open them all and keep only the ones that I still need. I know that it is possible to see the name of each window that is minimized by moving my cursor over the Firefox icon, but this does not provide enough information. So I have to open each window one at a time to look at it and then decide to close it or keep it - this is a frustrating, time-consuming process. Is there another way to open all the minimized windows at the same time, instead of one at a time?

    A possible cause is security software (firewall) that blocks or restricts Firefox or the plugin-container process without informing you, possibly after detecting changes (update) to the Firefox program.
    Remove all rules for Firefox and the plugin-container from the permissions list in the firewall and let your firewall ask again for permission to get full unrestricted access to internet for Firefox and the plugin-container process and the updater process.
    See:
    *https://support.mozilla.org/kb/Server+not+found
    *https://support.mozilla.org/kb/Firewalls
    You can retrieve the certificate and check details like who issued certificates and expiration dates of certificates.
    * Click the link at the bottom of the error page: "I Understand the Risks"
    Let Firefox retrieve the certificate: "Add Exception" -> "Get Certificate".
    * Click the "View..." button and inspect the certificate and check who is the issuer.
    You can see more Details like intermediate certificates that are used in the Details pane.

  • Okay, i have 2 bugs with maverick.  First, when I delete a file within a window, the files deletes but the preview doesn't delete until I close the window and reopen it.  Second, I work on a network of computers and the search feature is now buggy...

    Okay, i have 2 bugs with maverick.  First, when I delete a file within a window, the files deletes but the preview doesn't delete until I close the window and reopen it.  Second, I work on a network of computers and the search feature is now buggy...  When I search for a file, A) it asks me if it's a name, or it wont produce anything, and B), its slower than in prior OS versions and in some instances I have to toggle to a different directory and go back to my original directory in the search: menu bar or the search wont produce anything...  Very buggy. 

    It appears to me that network file access is buggy in Maverick.
    In my case I have a USB Drive attached to airport extreme (new model) and when I open folders on that drive they all appear empty. If I right click and I select get info after a few minutes! I get a list of the content.
    It makes impossible navigate a directory tree.
    File access has been trashed in Maverick.
    They have improved (read broken) Finder. I need to manage a way to downgrade to Lion again.

  • Memory could not be allocated for the activation process. Please close all applications and try agai

    I have just had a Windows XP failure and took the opportunity to replace with Windows 7.  After I reinstalled PhotoShop CS(1) the message "Memory could not be allocated for the activation process. Please close all applications and try again"  is shown and forces PhotoShop to close.  I have 4Gb of Ram installed and a total of about 10Gb of Page File space on three partitions of a 500Gb HDD.  The system is not heavily loaded!  However, I cannot access Photoshop to check scratch disk allocation.  How to fix???
    Back to top

    Yes, there are many forums, and it can be confusing. Your question has the best chance of being answered if it is in the proper place. I think it is there now.
    Pattie
    http://forums.adobe.com/message/5092533#5092533  is your post address
    Download and installation forum:
    http://forums.adobe.com/community/download_install_setup

  • How can I close all windows in Preview?

    Hi all
    I can't seem to find a way to close all windows in Preview.
    Can somebody try this and see if they get the same result I do.
    1. Copy an image into the clipboard.
    2. Open Preview
    3. Hold down command-N for about 20 seconds.
    You should end up with dozens of windows with the image that you copied.
    Now, try to close them.
    I've unchecked 'Restore windows when quitting and re-openng apps' in System Preferences
    I've typed in the 'defaults write com.apple.Preview NSQuitAlwaysKeepsWindows' hack in the terminal window
    I've quit Preview with the 'option' button held down and 'Quit and Close All Windows' showing in the menu.
    No matter what I do, the windows keep coming back every time I start Preview.
    This 'force restore' feature of Lion is starting to get really annoying.

    If I hold down the option key and go to Preview->File the Close Window menu item changes to Close all
    I answered the OP's question but I see now that the question wasn't what he was really asking.

  • Open a command window and send some keystroke to the opened command window

    Hi All,
    I am trying to open command prompt and send some key stroke to that command prompt. Here I am using Robot to send keystroke. But the problem is, the keystrokes are not sent to the prompt. I guess I need to activate progamitically the command prompt to accept the keystrokes . Please find the code below ( as I did).
    try
    String command = "cmd.exe /c start";
    Process child = Runtime.getRuntime().exec(command);
    Robot robot = new Robot();
    Thread.sleep(5000);
    String lol = "indranil";
    for(int i=0;i<lol.length();i++)
    robot.keyPress(lol.charAt(i));
    int g = lol.length() - 1;
    robot.keyRelease(lol.charAt(g));
    catch (Exception e) {}
    I guess I am doing some mistake here while sending the keystroke/openning the command prompt. Can anyone please help me how can I open a command window and send some keystroke to the opened command window. I am in fix.
    Thanks,
    Indranil

    The first thing to do is read the API and examples for the Robot class.
    Also check out this thread with a similar discussion: [http://forums.sun.com/thread.jspa?threadID=5385677]
    The short spoonfed answer - keyPress() and keyReleaseI() do not take chars. Read up on KeyEvent

  • Avoid "close all windows" form

    Hello guys,
    I'm just working on an add-on where there is the need to create several user defined tables and user defined fields at the beginning.
    During the creation, the B1-user gets the form "Database has been modified, close all windows" (no quote)
    And if he presses "Yes" to close all windows this could cause errors in the add-on.
    So my question is:
    Is there any possibility to get this form only ones (right after I finished creating the tables)
    Thanks in advance and
    Best regards,
    Mario

    Hi Mario,
    Take a look at the progressbar object. While a progressbar is active, a user can't interact with the GUI. I use this method also with my initialisations, works like a charm!
    <b>Code (C#):</b>
    /* Create a progressbar (10 steps, cancel button disabled) */
    ProgressBar pbProgress = m_SBOApplication.StatusBar.CreateProgressBar("Creating user tables", 10, false);
    pbProgress.Value = 1;
    /* Create a user table and set the progressbar value */
    pbProgress.Value = 4;
    /* Create another user table and set the progressbar value */
    pbProgress.Value = 8;
    /* Stopping the progressbar */
    pbProgress.Stop();
    pbProgress = null; /* <-- IMPORTANT! */
    Hope it helps,
    Rowdy

  • The window couldn't be opened because your computer is low on memory. Please close some windows and try again.

    When attempting to reply to or forward email, or to compose a new message in Outlook OWA I receive the following error message: "The window couldn’t be opened because your computer is low on memory.  Please close some windows and try again."  This
    occurs even if the web application is the only window open.
    My operating system is Windows 7.

    Hello,
    According to the error message, it should be a Windows issue.
    Try OWA and see if we can send/receive email properly. If OWA works fine, I suggest we post this question to Windows 7 Forum below:
    http://social.technet.microsoft.com/Forums/en/category/w7itpro
    Thanks,
    Simon Wu
    TechNet Community Support

  • When I close firefox window and later open firefox window it opens with blank page and nosidebar bookmarks

    when I close firefox window and later open firefox window it opens with blank page and nosidebar bookmarks

    Sounds like Firefox is "hanging at exit". That problem is frequently caused by an Extension or a Plugin. Read all of the following articles.<br /><br />
    #Stop the Firefox process:
    #*[http://kb.mozillazine.org/Kill_application Mozillazine - Kill application]
    #*Windows 7 users click [http://www.techrepublic.com/blog/window-on-windows/reap-the-benefits-of-windows-7s-task-manager/2576 here]
    #*Mac users: http://techheavy.com/2011/02/the-mac-task-manager/
    #Why Firefox may hang:
    #*[http://support.mozilla.com/en-US/kb/Firefox+hangs Firefox hangs] (see Hang at exit)
    #*[http://kb.mozillazine.org/Firefox_hangs Firefox hangs (Mozillazine)] (see Hang at exit and Closing Firefox properly)
    #*[https://support.mozilla.com/en-US/kb/Firefox+is+already+running+but+is+not+responding Firefox is already running but is not responding]
    #Use Firefox Safe Mode to find a problem with an Extension or Plugin:
    #*Don't check anything when entering Safe Mode, just continue
    #*If the problem does not occur in Safe Mode it is probably and Extension or Plugin causing the problem
    #*See:
    #**[[Safe Mode]] and [http://kb.mozillazine.org/Safe_Mode Safe Mode (Mozillazine)]
    #**[http://support.mozilla.com/en-US/kb/Troubleshooting+extensions+and+themes Troubleshooting extensions and themes]
    #**[http://support.mozilla.com/en-US/kb/Troubleshooting+plugins Troubleshooting plugins]
    #**[http://support.mozilla.com/en-US/kb/Basic+Troubleshooting Basic Troubleshooting]
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''

  • I mean that i phone take time to open apps ,contact ,etc why? i close all apps and the problem still?

    i mean that i phone take time to open apps ,contact ,etc why? i close all apps and the problem still?

    Try a reset by pressing and holding the home and power buttons for 15-20 seconds until the white Apple logo appears.

  • Memory could not be allocated for the activation process. Please close all applications and tr again

    Hello,
    Just purchased a new laptop:
    Intel Core 2 quad
    4gb memory
    1000 HDD
    Photoshop CS 8.0 disc dead/scratched/unreadable.  So I copied my Adobe folder from my Program Files Folder on my PC and pasted on laptop.  When I try and run PS I get the error message "Memory could not be allocated for the activation process. Please close all applications and try again". Which I do then Photoshop closes.
    Can anyone help (in layman terms please)?

    Not really. You are essentially FUBARd. Without a proper install, there is usually no way on to get the licensing stuff working. You might be able to get there by installing any other CS product, so PS could latch on to the licensing system that would be already in place, but otherwise it's a lost cause. Simply copying over the executables is normally not enough. I will admit though, that I skipped CS, so there may be some tool somewhere that I don't know about can do this post facto...
    Mylenium

Maybe you are looking for