Closing an applet window

I created a login button that when clicked a jframe pops up prompting for username and password. I created a "cancel" button in that window so if it is clicked the window is suppossed to close. I can't get it to work. I tried System.exit(0);

Have something like this in the JFrame object's event handling code:
setVisible(false);

Similar Messages

  • Exception when closing an Applet window

    Hi,
    Every one.....
    I have added Swing components to the JApplet. Everything is fine with the program . But when i am closing the appletviewer window it is throwing the following exception :
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: component argument pData
         at sun.awt.windows.Win32SurfaceData.initOps(Native Method)
         at sun.awt.windows.Win32SurfaceData.<init>(Unknown Source)
         at sun.awt.windows.Win32SurfaceData.createData(Unknown Source)
         at sun.awt.Win32GraphicsConfig.createSurfaceData(Unknown Source)
         at sun.awt.windows.WComponentPeer.replaceSurfaceData(Unknown Source)
         at sun.awt.windows.WComponentPeer.replaceSurfaceData(Unknown Source)
         at sun.awt.windows.WComponentPeer$2.run(Unknown Source)
         at java.awt.event.InvocationEvent.dispatch(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)
    So how to resolve this one, can anyone ?
    Bye

    I could be proven wrong, but I think you can use hide() and show() for your windows. You could make a windowListener that when a user tries to close the window you would have it hide that window instead, and show the underlying window:
    http://java.sun.com/docs/books/tutorial/uiswing/events/windowlistener.html
    You might also want to make the new window that pops up a modal dialog window.
    http://java.sun.com/products/jlf/ed2/book/HIG.Dialogs3.html
    Hope that helps.

  • Closing the applet window

    how to close the applet window using a button on the applet

    ravindra.alld wrote:
    how to close the applet window using a button on the appletIs your applet in a web browser? If so the only way to hide visibility of the applet would be through javascript and css. So you would need an html button outside the applet to do this.

  • Closing Parent Applet Window

    I am setting the seperate window = TRUE in my formsweb.cfg. This opens up the form as a seperate applet. This is what I want. But how do I close the window which loaded this applet? I want only the applet to be active, remaining all windows closed.

    I followed the recommendation, but in my case it doesn't work.
    The code
    HTMLbodyAttrs=onLoad='javascript:self.moveTo(2000,2000)'
    or
    HTMLbodyAttrs=onLoad='javascript:self.moveTo(1601,1201)'
    doesn’t work properly. I have noticed that if the browser original size is not full screen, then when that javascript code runs, the browser just moves down to maximum possible bottom position, but it doesn’t disappear or get minimized – browser window size doesn’t change.
    Who knows what the problem is?
    Thanks,
    Dmitri

  • No such element exception when applet window closed

    My applet can throw a NoSuchElementException as it closes during sudden death. The Java Console reports:
    Exception in thread "AWT-EventQueue-2" java.util.NoSuchElementException
         at java.util.LinkedList.getFirst(Unknown Source)
         at java.awt.SequencedEvent.getFirst(Unknown Source)
         at java.awt.SequencedEvent.dispatch(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)Sometimes that sequence displays once, sometimes twice. The error appears to be 90% or more repeatable.
    1) open link in new window http://r0k.us/graphics/SIHwheel.html
    2) view Color Log (menu item Help -=> Show Log)
    3) close the whole browser window
    It does not appear to happen without the dialog for the Color Log displayed. Nor does it appear to happen simply upon leaving that page. I'm guessing it is some sort of race condition as the applet is shut down and it doesn't have the surrounding window it started with. It only happens when running as an applet. When ran as a program, it always shuts down cleanly.
    It occurs less often if you:
    1) open the link in new window
    2) leave the page
    ) come back to it while the Java Console is still alive (before JVM goes away)
    3) view the Color Log
    4) close the browser window.
    I am running 64-bit Windows 7, and have observed this problem in Firefox, IE, and Chrome.
    With no hints as to where within my code this is occurring (if indeed it is within "my" code), I have no idea how to write an SSCCE. The exception seems to relate to enumerations, which I believe must be occuring during the shut down seqence. See:
    * http://download.oracle.com/javase/1.5.0/docs/api/java/util/NoSuchElementException.html
    What can I try doing to prevent the error from occurring? (Besides not closing the browser window while my applet is running and has a dialog open. ;) )
    *(added immediately before posting)* I just noticed that if any of the first three dialogs in the Help Menu are open, this behavior can occur. So it probably has nothing to do with the tables in the Color Log. The fourth, About, item is a simpler modal dialog, and you aren't even able to close the browser window while it is open.
    Now that I know the crash can happen with any of the non-modal dialogs, I will write an SSCCE, just to see if it occurs in a much simpler applet, if nothing else.

    As promised, an SSCCE with build instructions and an applet environment.
    CloseMyWindow.java import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.IOException;
    import java.net.URL;
    import javax.swing.*;
    public class CloseMyWindow  extends JApplet
        public JPanel makeContent() {
         JButton help = new JButton("Help");
         help.addActionListener( new ActionListener() {
             public void actionPerformed(ActionEvent e) {
              Dimension size = new Dimension(400, 250);
              HelpBox hb = new HelpBox("CloseMyWindow Help",
                  "cmwHelp.html", false, size);
         JPanel jp = new JPanel();
         jp.add(help);
         return jp;
        // method expected by applets
        public void init()
         try {
             javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
              public void run() {
                  JPanel frame = makeContent();
                  setContentPane(frame);
         } catch (Exception e) {
             System.err.println("makeContent() failed to complete: " + e);
             e.printStackTrace();
        public static void main(String[] args)
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    JFrame frame = new JFrame("Test");
                    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                    frame.add(new CloseMyWindow().makeContent());
                    frame.pack();
                    frame.setVisible(true);
    class HelpBox extends JDialog
    {   // general window for display of HTML page
        HelpBox(String title, String pUrlS, boolean modal, Dimension pSize)
         super((Frame)null, title, modal);
         final String     urlS  = pUrlS;
         final Dimension     size  = pSize;
         SwingUtilities.invokeLater(new Runnable() {
             public void run() {
              setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
              JEditorPane ep = new JEditorPane();
              ep.setEditable(false);
              try {
                  URL url = getClass().getResource(urlS);
                  ep.setPage(url);
                  JScrollPane eps = new JScrollPane(ep);
                  eps.setPreferredSize(size);
                  getContentPane().add(eps, BorderLayout.CENTER);
              } catch (IOException ioE) {
                  System.err.println("Unable to display help pane");
                  ioE.printStackTrace();
              pack();
              setLocationRelativeTo(null);
              setVisible(true);
    }cmwManifest.txt (be sure to end line with a carriage return) Main-Class: CloseMyWindowcmwHelp.html <html>
    <head><title>Help for CloseMyWindow</title></head>
    <body>
    Good, you've opened this dialog.  Now close the browser window containing
    my applet.
    </applet>
    </body>
    </html>cmw.html <html>
    <head><title>Close My Window</title></head>
    <body>
    <applet code="CloseMyWindow.class"
            archive="CloseMyWindow.jar"
            width="450" height="300">
    Your browser is completely ignoring the <i>applet</i> tag!
    </applet>
    </body>
    </html>1) capture the 4 code segments above and save them as correspondingly-named files.
    2) compile:
    ] javac CloseMyWindow.java
    3) build the jar:
    ] jar cvfm CloseMyWindow.jar cmwManifest.txt *.class cmwHelp.html
    4) test the jar:
    ] java -jar CloseMyWindow.jar
    5) run the applet. Open page cmw.html in a new browser window
    6) enable Java Console (mine is set to autostart on any applet or JNLP)
    7) click the applet's Help button. A new dialog should open up.
    8) close the browser window
    9) observe if an error is reported in Java Console
    I am seeing the error in this small applet. Maybe the .java file will give you guys some clues.

  • Closing applet window

    i have two Q:
    1) how do i close applet window ?
    2)how can i know that the X button of the applet window was pressed?

    1) You don't...the browser takes care of that!
    2) In IE, the applet's stop and destroy methods are called when the user moves from your HTML to another or the window is closed. In NN4+, the applet's stop method is called when the user moves away from your HTML and the destroy method is call when the window is closed. I don't bother with NN6.2+ because to me it's still a beta product based on Mozilla version .9 something and is so slow.
    V.V.

  • Using separate_frame=true and trying to close the applet window after...

    We are using separate_frame=true and trying to close the applet window (the one with the large gray box) after using the following post-form trigger:
    if :system.last_form = 0 then     
         message('Please wait while Forms closes - '||:system.last_form);     
         web.show_document('/forms/html/close.htm','_self');     
    end if;
    This works fine for the first form we open, but if that same form using Open_Form to open a child form we have a problem. When the child form is closed the user is returned to the parent calling form (which is expected), but then when the parent form is closed the separate applet window fails to close. Any suggestions?

    I guess you mis-interpreted the value of :SYSTEM.LAST_FORM. From the online-help:
    SYSTEM.LAST_FORM represents the form document ID of the previous form in a multi-form application, where multiple forms have been invoked using OPEN_FORM.So LAST_FORM shows always the ID of the last activated form, and this will never be 0 if you issued one OPEN_FORM in your application.

  • Unsigned Java Applet Window

    Hi,
    I have an Applet which can pop-up a JAVA application window.
    But the bottom bar of that pop-up window says " Unsigned Java
    Applet Window". And I am not able to close the window without
    closing the first Applet window. Need some help. Thanks.

    But the bottom bar of that pop-up window says "
    Unsigned Java
    Applet Window". You can't get rid of this without signing
    And I am not able to close the window
    without
    closing the first Applet window. Need some help.you need a window listener (you can use window adapter)
    newFrame.addWindowListener (new WindowAdapter () {
    public void windowClosing (WindowEvent we) {
    setVisible(false);
    dispose();
    Thanks.

  • Closing of Applet(Very Urgent)

    Hai All
    A issue to be solved. I have on JApplet and a JOption is displayed on some conditions..on the click of the button in the JOption the applet has to be closed. How can the Applet be closed on some conditions. I used system.exit..it is not doing the thing...
    Thanks in Advance

    But that method will not close the applet window.....

  • Open URL in a new window by closing the parent window

    Hi Friends,
    Is there any option to open URL in a new window by closing the parent window on a button click?
    Already implemented the logics suggested in /people/mohammed.anzys/blog/2007/06/05/how-to-close-parent-window-in-webdynpro-applications , the thread ' URL in same window '  and the standard component WDR_TEST_EXIT_PLUG .But button is not triggerring any actions .plz help me  ..............
    Regards,
    Radhika

    hi,
    Do the following steps :
    -> Make an Outbound Plug to the Window.
    ->Make the type of Outbound plug to Exit Type.
    ->Add URL of type String as a parameter to the outbound plug of Window.
    ->Do remember to add Component Name in the Properties Tab of View ( othervs Calling Outbound plug of window from view wont b possible ).
    To open a new URL with closing the previous one write this Code in OnAction of Button : ( this Code can be get from Code Wizard too ).
    DATA lo_zexit TYPE REF TO ig_zexit .   <zexit is name of my Component>
    lo_zexit =   wd_this->get_zexit_ctr( ).
      lo_zexit->fire_out_window_plg(
        url =   'http://www.google.com'                            " string
    I hope it helps.
    Thanx.

  • I have updated my iTunes to the newest version, 10-25 on a windows XP system. Now my java virtual machine is not working and I need it to run applet window. My Java is also newest version. What can I do to fix/repair my issue?

    I need help with java on windowsXP after updating iTunes to the latest version. My java will not work and I get error message need java virtual machine to run applet window. Did not have this problem prior to the iTunes update.
    Please help, Thanks

    If your library was working on your computer and then popped up empty all of a sudden then this might be what you need...
    Empty/corrupt library after upgrade/crash
    Hopefully it's not been too long since you last upgraded iTunes, in fact if you get an empty/incomplete library immediately after upgrading then with the following steps you shouldn't lose a thing or need to do any further housekeeping. In the Previous iTunes Libraries folder should be a number of dated iTunes Library files. Take the most recent of these and copy it into the iTunes folder. Rename iTunes Library.itl as iTunes Library (Corrupt).itl and then rename the restored file as iTunes Library.itl. Start iTunes. Should all be good, bar any recent additions to or deletions from your library.
    See iTunes Folder Watch for a tool to catch up with any changes since the backup file was created.
    When you get it all working make a backup!
    tt2

  • I want to reset Firefox, and the message is that something is preventing the reset. I have closed all open windows and I still get the "Oops" message,

    I have uninstalled and reinstalled Firefox because I was receiving unwanted adware and was being directed to untrusted sites. Now I want to reset Firefox because I want to change the home page and toolbars, and something is preventing the reset. I have closed all open windows repeatedly, but the problem continues.
    =====Moved from Firefox OS product to Firefox for Desktop product category by Moderator. -feer56=====

    Check the programs that are on your computer
    '''Windows:''' Start > Control Panel > Uninstall Programs.
    '''Mac:''' Open the "Applications" folder
    '''Linux:'''
    * [http://www.freesoftwaremagazine.com/articles/see_all_your_installed_applications_ubuntu_unity Ubuntu Unity]''' {web link}
    * Xfce: Applications Menu category sections
    * options depends on the package manager and the desktop environment
    Go thru the list. If you find something that you don't
    know what it is, use a web search.
    '''''[https://support.mozilla.org/en-US/kb/troubleshoot-firefox-issues-caused-malware Troubleshoot Firefox Issues Caused By Malware]''''' {web link}

  • Why does closing all open windows (15) and leaving only one drop ram usage from 1.5 to 1.4Gb and not more.

    Why does closing all open windows (15) and leaving only one drop ram usage by only 100mb from 1.5 to 1.4Gb.
    What is in this 1.4 gb ?
    I don't care much about ram, It's just that cpu usage spike like crazy by the end.
    ''Edited to remove swearing - TonyE''

    Hi musicfan,<br />Sorry you are having problems with Firefox. Maybe you should have asked earlier and we could have fixed it.
    Reading your comments I do not see that rolling back to an insecure Firefox 22 will actually help you much. You are probably best using IE, unless you have also damaged that.
    *[[Export bookmarks to Internet Explorer]]
    You should not use old versions they are insecure. Security fixes are publicised and exploitable.
    * [[Install an older version of Firefox]]
    * https://www.mozilla.org/security/known-vulnerabilities/firefox.html
    Most others will not be having such problems. We are now able to say that with confidence because after developers missed a regression in Firefox 4 telemetry was introduced so that data was obtained. It may be an idea to turn on your telemetry, if you have not already done so, and decide to stick with Firefox.
    *[[Send performance data to Mozilla to help improve Firefox]]
    Trying safe mode takes seconds. Unfortunatly if you are not willing to do even rudimentary troubleshooting there is not anything we can do to help you.
    *[[Troubleshoot Firefox issues using Safe Mode]]

  • My 3 year-old macbook pro is very slow. I have run disk utility and virus scan with no improvement. The "beach ball" will spin for minutes at a time when opening, closing or changing windows. Apple Store looked at it a few months ago with no help.

    my 3 year-old macbook pro is very slow. I have run disk utility and virus scan with no improvement. The "beach ball" will spin for minutes at a time when opening, closing or changing windows. Apple Store looked at it a few months ago with no help. What can I do?

    Under CPU: 3.5% user; 5% system; 91% idle; 441 threads; 90 processes.
    Under System: out of 2GB - 54.7MB free; 530MB wired; 603MB active; 862MB inactive; 1.95GB used.
    Is too much of the system memory tied up? If so, what can I do to free some up?

  • Java Applet Window Warning - Appearing through

    Hello
    The warning that is displayed on applet windows now when using java is causing a problem.
    When you bring a fresh web page or word document over the top of the applet window, the java applet warning is still visible as if it has been brought to the front layer. but the rest of the applet is behind the new active window.
    Really weird.
    Ben.

    Our team is also using a signed applet and are having trouble with popup items not being accessible outside of the JFrame.
    In appletviewer the popup (JXDatePicker) is fully accessible. If running in Internet Explorer on Windows 2000 the portion of the popup outside of the JFrame paints correctly but cannot receive click events correctly.
    It would be preferrable that if the popup cannot receive events outside of the applet frame that the popup would be smart enough to pop itself fully in the applet frame.
    Any suggestions?
    Thank you.

Maybe you are looking for