Close JPanel and JDialog

Hi.
I'm writing a software with one frame and in its contentPane in made up with two JPanel which changes continuously. The problem is that when I close that main frame the whole computer stops and seemes to enter into deadlock.
Can someone tell me which is the best method to close frames, dialogs and panels (I think it's the reason for my problem).
Now I'm using setVisible for panels and dialogs.
Thanks

Try something like :-
public class MyFrame
             extends JFrame
    public MyFrame()
        setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
        addWindowListener(new WindowAdapter()
            public void windowClosing(WindowEvent wndwEvnt)
                dispose();
                System.exit(0);
}There are other constants (e.g. WindowConstants.DISPOSE_ON_CLOSE if memory serves), that you can use depending on what you want to do when you 'close'.

Similar Messages

  • Can we add same JPanel twice??.. on JFrame and JDialog together!!

    Hello Frnds,
    my problem is quite weird!! i will try to explain..as much as I can !!
    My requirement is I want to show same JPanel in JDialog and JFrame at once..!!
    I am adding a
    JPanel A ---> JDialog
    JPanel A ---> JScrollPanel B
    JScrollPane B ---> JFrame.. and making frame and dialog visible together.. but JPanel is visible in dialog only..
    if i dont add in JDialog.. then JPanel is visible in frame.. !!.. but why that??
    JFrame fr = new JFrame();
    JPanel np = new JPanel();      // This JPanel is added Twice
    np.setBounds(0, 0, 128, 128);
    JScrollPane scroll=new JScrollPane(np);      // Once JPanel added here..
    scroll.setPreferredSize(new Dimension(385,385));
    fr.add(scroll);
    JDialog dlg=new JDialog(fr, "Another Panel", false);
    dlg.add(np);                        // Second Time JPanel added here..
    dlg.pack();
    dlg.setVisible(true);
    fr.setVisible(true);

    Let's make it very clear : it is NOT possible to add
    the same instance of a component to two different
    containers.
    Is it possible to have frame with component.. but on closing that frame component shifts to another frame.. and vice versa I will add to the above:
    it is NOT possible to add the same instance of a component to two different containers... at the same time. Does that clarify it?
    Why is it so hard to try it yourself?
    Instead of waiting a couple of hours hoping someone answers the question you could have solved your problem in a couple of minutes.

  • Error on my IPad 2. When I'm trying to access in utilities to configure the email, this close suddenly and send me to home page

    Error on my IPad 2. When I'm trying to access in utilities to configure the email, this close suddenly and send me to home page.

    Not sure about Utilities on your iPad. Do you mean the Settings app?
    First thing to try is a reboot of your iPad. Press and hold the Home and Sleep buttons simultaneously ignoring the red slider until the Apple logo appear. Let go of the buttons and let the iPad restart. See if that fixes your problem.

  • When I close Firefox and then try to open it, it says it is already running and I have to close it which I can't do. The only way to open it is to first restart my computer which is a pain. If I can't fix this I will use an other brouser!

    I am not sure what more I can tell you. I close firefox. So when I click on the icon it should allow me to open it again but I get a message that says it is already running. Either close it out which I can't do since I already did that or restart the computer.

    Try holding control, alt and delete down in succession and then a dialogue box will appear with windows task manager. Once open click on the Processes Tab and look for firefox.exe. Highlight this and then click end process. It should come up with a warning but just click Yes. This should then close firefox and allow you to reopen it from your desktop without shutting down your computer. Hope this helps.

  • When i close firefox and want to use it later i get a warning saying cannot open firefox close it first this keeps happening all the time any ideas to solve this problem? i have 2 mchines one on xp and one on windows 7

    i have 2 pcs one with xp and the other with windows 7 heres the problem
    when i close firefox and say go back to it say in 10 mins i get a error message saying to close firefox before opening!!! but firefox window is closed but the processes still say its running in task manager so to correct this i have to end process on firefox. this seems to be happening now every time in the last few days i have upgraded firefox to the latest version. any ideas on how to solve this problem.

    see if this helps you : [https://support.mozilla.org/en-US/kb/Firefox%20is%20already%20running%20but%20is%20not%20responding Firefox is already running but is not responding]
    thank you
    Please mark "Solved" the answer that really solve the problem, to help others with a similar problem.

  • HT5361 I can't shut down my computer because it says mail is open.  It says to close mail and continue shut down.  Problem is I can't open or close mail now.  Can't shut down my computer at all.  What can I do?

    I can't shut down my computer because it says mail is open.  It says to close mail and continue shut down.  Problem is I can't open or close mail now.  Can't shut down my computer at all.  What can I do?

    If you cannot get mail to quit/force quit, you can always remove power from your Mac.
    NOTE: removing power is a bad idea, and can result in data loss, but sometimes it is the only thing left to do.
    Press and hold the power button for 5 to 10 seconds, and the Mac will power off.
    When you power back on, the Mac should reboot.

  • Open/Transfer/close Dataset and delimiting

    Hi people hi have a situation regarding open/transfer/close dataset and delimits.
    I have a submit program that calls any other via variants. It works fine with using list_to_memory, convert to ascii, and open dataset. I can download the report in excel format to an application server.
    Problem is that the reports arent delimited properly in the excel report. Usually there is a vertial line "|" placed after each column and it would be eazy to mauiplate it during viewing the actual file.
    However I want this done automatically. My question is, is there a way to delimit the list before/during using open/transfer/close dataset?
    My solution before was to convert the vertical lines to a comma and just save the file as a CSV file. Problem here is the data could be affected as comma is being used normally. So the excel report would get messed up.
    Hope I get some help soon. Thanks guys and good day.

    Lets say you have fields A, B, C and D to be transfered to the dataset. You can use the below logic.
    concatenate a b c d into l_text separated by '$'.
    transfer l_text to dsn.
    Now, when you open the text file in excel it would ask you whether the file is delimeted or fixed width...if you select delimited..in the next screen you would be able to select the delimiter.
    Regards
    Anurag

  • FF doesn't open a new window , and doesn't open at all when I close it and try to open it again.

    Initially when I start my PC Windows 7 Ultimate , FF opens fine , but it doesn't open a new window when I click on the option "Open a new Window " in the taskbar .When I right-click a tab and select the option "Move to a new Window" then too it doesn't work. Next when I close FF and and try to reopen it , it doesn't open at all.I have FF v34.0.5.

    Gnome-shell issue. You can disable desktop management as a temporary fix, but the next gnome-shell update will fix the problem.
    https://bbs.archlinux.org/viewtopic.php?id=175993
    https://bugzilla.gnome.org/show_bug.cgi?id=722510
    https://bugzilla.gnome.org/show_bug.cgi?id=722690

  • How to change default close maximize and minimize button in mac?

    How can I change default close, maximize and minimize button in mac?

    no. but you can make resizable.

  • I had 41 tabs open in about six groups over the last year and a half and I just close them and exited Firefox. Is there any way to get them back?

    <blockquote>Locking duplicate thread.<br>
    Please continue here: [[/questions/856718]]</blockquote>
    I had 41 tabs open in about six groups over the last year and a half and I just close them and exited Firefox. Is there any way to get them back?
    Also, is there any way to save a group or an open session and then restore it later?

    History menu, if it was destroyed in the last session
    then use "Restore Previous session:" and then restore all windows also from the history menu.
    If done in this session try the restore all windows under the history menu.

  • I just downloaded Lion and when it opened mail for the first time, I received an error that there was something corrupted in mail.  I was directed by Apple to close Mail and re-open it.  I did, but now Mail will not open at all.  What do I need to do to c

    I am having issues with Mail after downloading and installing Lion.  Snow Leopard prior.  There was a message that there was some sort of corruption in Mail and that I should close Mail and re-open Mail.  I did, but Mail will not open at all.

    Try the following user tip:
    Troubleshooting issues with iTunes for Windows updates

  • Whenever I reply to an e-mail the window comes up but without the paper airplane in the top left corner.  The only way to send the reply is to close it and save as a draft.  Then I can pull it up from Drafts and it has the airplane on it.

    Whenever I reply to an e-mail the window comes up but without the paper airplane in the top left corner.  The only way to send the reply is to close it and save as a draft.  Then I can pull it up from Drafts and it has the airplane on it.

    Launch Mail.
    Click "New Message" in the Toolbar.
    When the new message window opens up, click "View" menu in the menu bar.
    Select "Show Toolbar" from the dropdown.
    or
    Select "Customize Toolbar from the dropdown.
    When the Customize Toolbar sheet drops down, drag  "Send" button
    or  drag "default set" into the toolbar.
    Click "Done".

  • After removing the "Live Security Platinum" virus, Firefox crashes every time I close it and it runs very slowly (v14.0.1). Is there any way to fix this?

    Firefox doesn't exactly crash while I'm using it. The thing is that when I close it and reopen it, it says it crashed and offers to restore the previous session. To my knowledge, this didn't happen until after I had the "Live Security Platinum" virus and removed it. Firefox is also very, very slow. Has anyone else had this particular problem?

    Hi there, sorry about your problems. It could be that the virus remover didn't fully clean up Firefox.
    Try the Reset Firefox feature, which should restore it back to a normal working state without removing your personal data such as bookmarks: https://support.mozilla.org/en-US/kb/reset-firefox-easily-fix-most-problems?s=reset+firefox&r=0&e=es&as=s#os=mac&browser=fx13

  • When I close Firefox and then come back to it layer a box comes up that says it's already running. It ays to close Firefox first but when I hit close nothing happens and the box comes up again. I have to shut down my computer and restart to get into Firef

    When I close Firefox and then come back to it later a box comes up that says it's already running. It says to close Firefox first but when I hit close nothing happens and the box comes up again. I have to shut down my computer and restart to get into Firefox again. If I can't get this fixed I will start using someone else. Someone told me a way to close Firefox but I forgot what they said.
    == This happened ==
    Every time Firefox opened
    == a couple of months ago

    Hello Brian.
    You don't need to restart your computer to open Firefox again: you just need to close it manually through your application manager (CTRL+SHIFT+ESC in Processes tab). Anyway, hopefully this support article is what you need:
    http://support.mozilla.com/en-US/kb/Firefox+hangs
    What's probably happening is that you may be having a problem with some Firefox add-on that is hindering your Firefox's normal behavior. Have you tried disabling all add-ons (just to check), to see if Firefox goes back to normal?
    Whenever you have a problem with Firefox, whatever it is, you should make sure it's not coming from one of your installed add-ons, be it an extension, a theme or a plugin. To do that easily and cleanly, run Firefox in [http://support.mozilla.com/en-US/kb/Safe+Mode safe mode] and select ''Disable all add-ons''. If the problem disappears, you know it's from an add-on. Disable them all in normal mode, and enable them one at a time until you find the source of the problem. See [http://support.mozilla.com/en-US/kb/Troubleshooting+extensions+and+themes this article] for information about troubleshooting extensions and theme. You can troubleshoot plugins the same way.
    If you want support for one of your add-ons, you'll need to contact its author.

  • Can't open Firefox. When I try to open, a window pops saying "Close Firefox" and "A copy of Firefox is already open. Only one copy of Firefox can be open at a time.", and doesn't allow the application to open.

    Came home to find computer restarted, which I assume is an automatic Firefox update.
    When I try to open Firefox, window pops up saying "Close Firefox" and, "A copy of Firefox is already open. Only one copy of Firefox can be open at a time."
    I'm unable to open the program at this time, lots of critical work info stored there - please help. Thx.
    Neal

    See "Hang at exit":
    *http://kb.mozillazine.org/Firefox_hangs
    *https://support.mozilla.com/kb/Firefox+hangs

Maybe you are looking for

  • WRT160N G wireless Laptop connects to internet and N Laptop does not

    I have a WRT160N router with 1 wired and 2 wireless computers. The wired and G wireless connect to the internet work fine. The new laptop is wireless N and was connecting to the internet but now looks as if I have completely lost the wireless N in th

  • Call and Execute Multiple Windows of the same VI

    Hi, I would like to call and execute multiple windows of the same VI. Please take a look for my attached vi, and start from the 2x2.vi, i think you have to re-enter the file path to run (sorry for inconvenience). If I click the start button in differ

  • What is this Time Machine?

    Hi All, I currently have a 24" iMac C2D and have a LaCie FW HD partitioned to backup my entire volume and my Home folder. I use Silverkeeper and the Backup volume is completely bootable. I thinking of upgrading to Leopard and wonder if Time Machine w

  • How can I limit number of responses to my class registration?

    Hi guys, I am running few class registration, each class can take 100 students max. So I would like the web registration form stop taking more entries once 100 people responded attendance. How can I achieve that thanks.

  • IOS with MPLS for 2610XM ?

    There is no image with mpls that I can find, the lowest router is the 2651xm. However for my home lab I have 2610XM maxed out with 256meg mem and 48meg flash. Is there any IOS I can run that will allow me to configure MPLS VPN ? Thanks