Closing an Applet

I want to close an applet at the click of a button.
After adding the listener, the code looks like:
privte void jButton1MouseClicked (java.awt.event.MouseEvent evt) {
stop();
Does not work. Neither with destroy() instead of stop(), nor with both.
How do I close an applet?
Thanks, everybody

public void stop()
You need to overide the method, which suspends the applets' thread execution.
public final void stop(Throwable obj);
Abruptly terminates execution of the thread.
The argument, if specified, is an exception that the thread throws.
If no argument is specified, stop() generates a ThreadDeath exception.
This call, interrupts the thread in the middle of whatever it is doing.
public final void stop()throws SecurityException;
This call, stops all threads in the group.
With running Threads with start(), stop() and run(), you have to redefine your class ie:
public class MyAppletClass extends java.applet.Applet
implements Runnable {
Thread runner;
     public void start() {
     if (runner == null) {
          runner = newThread(this);
          runner.start();
          public void run() {
          // your applet does something here
     public void stop() {
if (runner != null) {
runner.stop();
runner = null;
regards,

Similar Messages

  • Know if user has closed the Applet?

    I mad this chat without socket connection, so now I want to know if a user has closed the applet where the chat is..... Is this possible ? Can I somehow registre that a user doesnt have the applet running in his computer anymore?

    I assume that the destroy() method of the Applet class will run when the user terminates the applet (however this might take a while after the user navigates from the applet page). Otherwise, the start() and stop() methods could be used for this purpose. Run a test to see when these methods are invoked for your applet (navigating to and fro, shutting down the browser etc.) and figure whether these can do the work for you.

  • 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.....

  • 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

  • Opening and closing an applet or closing a webpage

    Hi,
    i was wondering if it was possible to open an applet from inside one method and close it within another method. I do not seem to be able to do this.
    I have however opened a HTML page that contains the applet and this appears to work fine. Can i, in another method close this HTML page that i opened?
    Cheers,
    Gareth.

    Yes you can, using javascript. What I recommend is to open the new page containing the applet with a call to a javascript function in the page that is running the original applet. Then, call another javascript function that closes the window that was opened. For example
    //this code make a call to the javascript function open_applet
    JSObject obj = new JSObject();
    obj.call("open_applet",null);
    //this code make a call to the javascript function close_applet
    JSObject obj = new JSObject();
    obj.call("close_applet",null);Now, on your html (or jsp) page, just put the following:
    <script>
    var mywindow;
    function open_applet(){
    mywindow = window.open("url","_new");
    function close_applet(){
    mywindow.close();
    </script>
    Hope you can use this! Regards!

  • Closing the Applet when I exit the form

    I am deploying an application on web plataform using Forms Server 6i. I have created my own base.html with a logo and a menu as appropiate. I am using Oracle JInitiator to run the forms. When I run a form, the applet is loaded in a frame created in my base.html. All is working fine, but, when I exit the form, I supposse the applet it's still there, because in the page a gray rectangle still remains. I would like to have a background image in the page, and when I close the form, the applet was unloaded, so I can view the background again. How can I get that.
    Thanks.
    P.D.: Sorry but my english it's not so good.

    Make a new project and import old one into this new one.
    See if you can find a up to date Auto Save.
    Also make a habit of 'Save A Copy' to a different drive after each edit session. Save A Copy does not overwrite after so many times as Auto Save does.

  • Refresh an open web page on closing an applet launch from Java Web Start

    Hi
    I launch an aplication via Java Web Start from a link in a web page. I am looking to a solution to refresh my web page when I close my applet.
    Thanks in advance to give me the solution or only to let me know if it's possible or not.

    everything's possible. but this is not trivial. there is no direct connection between the html page that launched the app and the app. You can create an indirect connection by having the app notify a server process when it closes and having the page periodically polling the server for the app's status.

  • Closing an applet  from jsp

    Hi All,.
    Iam facing a problem..pls help me in this..
    i am calling a jsp which is running on other server and from their i am calling an applet..
    pls see the code ie subnav.jsp
    here sp.document.manager.url=http\://localhost\:90/inventx/login.jsp?Return Path=http\://localhost\:90/inventx/spdocs.jsp
    <%String docURL = PropsUtil.get("sp.document.manager.url");%>
    var actionValueId = document.getElementById("localPlanId").value;
              spdocURL = "<%= docURL %>"+ "?Ids=" + actionValueId + "-" + tab +"&userId=" + "<%= userId %>" + "&passwd=" + "<%= encryptedPasswd %>";
              window.open(spdocURL,'spWindow') ;and here is spdocs.jsp
    <%
         String path = request.getPathTranslated( );
         int index = path.lastIndexOf( java.io.File.separatorChar ) + 1;
         Object obj = getServletContext( ).getAttribute( "epm_port" );
         String port = obj == null ? "6060" : obj.toString( );
         String Ids = request.getParameter("Ids");
         String id[] = Ids.split("-");
         String LOCALE = com.inventx.locale.LanguageLocale.getLocale( ).toString();
         java.io.File jar = new java.io.File( path.substring( 0, index ) + "epm/epm.jar" );
         String epmLastModified = new Long( jar.lastModified() ).toString( );
    %>
    <HTML>
         <HEAD>
              <TITLE>Inventx: Product Downloads</TITLE>
              <SCRIPT LANGUAGE="Javascript">
                   function insertLink( ) {
                        document.write( "<td><APPLET id=app CODEBASE=epm CODE=com.inventx.applet.ClientApplet ARCHIVE=\"client.jar\" WIDTH=70 HEIGHT=22>" );
                        document.write( "\t<PARAM NAME=CABBASE VALUE=client.cab>" );
                        document.write( "\t<param name=\"COOKIE\" value=\"EPM_SESSION_ID=<%= session.getId( ) %>\">" );
                        document.write( "\t<param name=\"PORT\" value=\"<%= port %>\">" );
                        document.write( "\t<param name=\"PLANID\" value=\"<%=  id[0] %>\">" );
                        document.write( "\t<param name=\"VERSION\" value=\"1.1.1\">" );
                        document.write( "\t<param name=\"CLIENT_ID\" value=\"\">" );
                        document.write( "\t<param name=\"BLANK_WINDOW\" value=\"true\">" );
                        document.write( "\t<param name=\"APPLICATION\" value=\"<%= id[1] %>\">" );
                        document.write( "\t<param name=\"LOCALE\" value=\"<%= LOCALE %>\">" );
                        document.write( "\t<param name=\"EPMLASTMODIFIED\" value=\"<%= epmLastModified %>\">" );
                        document.write( "</APPLET></td>" );
              </SCRIPT>
         </HEAD>
         <BODY style="background-color: #FFFFFF">
              <table align="center">
                   <tr>
                        <SCRIPT><!--
                             insertLink( );
                        //--></SCRIPT>
                   </tr>
              </table>
         </BODY>
    </HTML>this will lanch the applet...
    now my problem is i have to close this applet..while the user signing out from the main application...
    and here is the logout.jsp
    <%
         com.inventx.Utilities.ClientContext context = getClientContext( request );
         if ( request.getParameter( "Confirm" ) != null && request.getParameter( "Confirm" ).equals( "Yes" ) ) {
              try{
                   //context.getSession().executeMethod(this, "createFolder");
                   System.out.println("Context in logout jsp---"+context.getUserID());
                   System.out.println("Context in logout jsp---"+request.getRemoteAddr());
                   com.inventx.terminateClient.Terminate terminate = new com.inventx.terminateClient.Terminate();
              terminate.sendInstructionToClient(context,request.getRemoteAddr(),session.getAttribute("USER_ID").toString());
                   //context.getSession( ).executeMethod( this, this, "receiveInstruction", false, null );
              } catch (Exception e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              session.invalidate( );
              response.sendRedirect( ".." );
         } else {
    %><html>
         <head>
              <title>Inventx: Logout</title>
         </head>
         <body bgcolor="black" text="white">
              <form enctype="application/x-www-form-urlencoded" method="post">
                   <input type="hidden" name="Confirm" value="Yes">
                   <table align="center">
                        <tr>
                             <td><img src="../images/login.gif" border="0"></td>
                        </tr>
                        <tr>
                             <td> </td>
                        </tr>
                        <tr>
                             <td align="center"><table>
                                  <tr>
                                       <td>Are you sure you wish to logout of the InventX ePM System?</td>
                                  </tr>
                                  <tr>
                                       <td><input type="submit" value="Logout"> <input type="button" value="Cancel" onClick="history.back( )"></td>
                                  </tr>
                             </table></td>
                        </tr>
                   </table>
              </form>
         </body>
    </html><%
    %>pls help me in this..
    Thanks in advance..
    Sathya

    Then the answer is no. The Applet doesn't exist until it is instanciated by the browser so the JSP running on the server can not pass Java Objects. You can either set up a javascript array, set the parameter tags in the HTML Applet tag or have the Applet open a URLConnection back to the server.

  • Closing one applet and open another...

    Hi all,
    What I currently have is a very basic applet that requires you to type in your password and follow by pressing the OK button. What I want it to do is following the pressing of the OK button, I want that initial applet to close and have another applet open. It doesn't seem too over the top difficult but right now I have no idea. Please help.
    Thank you

    I do work with applets. Reply #4 is the correct one IMHO.
    If you don't understand what he is saying, I will try to put it
    in other words.
    1. Login dialog. Once your applet starts, it will display nothing
    essential, perhaps just a nice background and it will open a
    dialog for userid-password. If authentication is ok, close the
    userid-password dialog and display in your applet whetever you
    have in mind.
    2. Card layout. Your applet will start by asking for userid-password
    in its area inside the page. When authentication ok, display whatever
    the applet is supposed to display.
    In both scenarios, there are no two applets, but a single applet that
    changes from state 1 (authentication) to state 2 (display data).
    The only difference between the two scenarios is aesthetic,
    i.e. do you want a popup for userid-password or you want it inside the
    page? I would go with the card layout. Both are relatively easy.

  • Browser closing when applet is loaded

    Hi,
    As you can see from the forum list i'm having soooooooo much problems with my applets!
    Please can some one point me in the right direction!
    When my applet loads the browser tells me that the main class is loaded but then closes with for no apparent reason!
    Does anyone know why?
    Regards
    Richard

    It appears from the following statement that a native code process failed when called by the jvm.
    The crash happened outside the Java Virtual Machine in native code.Not much more can be said. The cause does not appear to Java code.

  • 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 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);

  • After closing an Applet, how can I say a HTML/JSP Site to load a new site?

    Hi!
    I have a problem. I�m writting a little chat, and after qutting I want to say my HTML/JSP site to load or go further to another page.
    This is possible because a saw this already, but i didn�t got the way how!
    Thnx
    Ren�

    Hi,
    I assume you mean with "after quitting" pressing the Quit button.
    Your JSP can use the forward-statement to move to another JSP or HTML. You can find it on Suns
    JSP-Syntax Card.
    I hope I could help you
    Frank Rettweiler

  • How to tell embedded jinitator applet is still running when window closed

    Hello, we are trying to accomplish the same thing that is mentioned in this post from Metalink. I've searched for a solution and hope someone here can help. Instead of restating the issue I think David Wilson does a good job of explaining what is needed. Can anyone please suggest a possible solution?
    From: David Wilton 07-Oct-05 01:08
    Subject: How to tell embedded jinitator applet is still running when window closed
    How to tell embedded jinitator applet is still running when window closed
    Hi,
    We run an oracle 10g forms application through 9iAS over an intranet. All users are running windows 2000 professional.
    We run separate frame = true but I would like to switch to separate frame = false
    With separate frame = true if the user clicks the outer windows "X" close button (forms mdi window) the user is prompted to save changes before the application ends.
    BUT
    when using separate frame = false
    If the user clicks the upper window "X" button (no longer form mdi window but regular browser window) the window and application is abruptly closed.
    I'm interested in using a onbeforeunload function to confirm if the user wants to close the window. This would be placed in the basejini.htm file. This could always ask if the user wants to exit or not. If they click OK then the window closes but if they click "Cancel" you are returned to the forms application exactly where you left. something like event.returnvalue="do you really want to exit?";
    However if the user exited using the normal exit form method then the applet is already closed before the onbeforeunoad event fires and there is nothing to go back to and I want the window to close automatically. This is accomplished using close.html file in post forms trigger.
    So what I want and what I think many may also want is the check if the embedded applet is still running and if so prompt the user to return to the application or continue to close. Of course If the applet is no longer running then just close because there is no reason confirm closing anymore.
    Does anyone have a html/JavaScript solution that can be placed in the jinitiator.htm file? or similar?
    Thank you
    David
    [email protected]
    From: Andrew Lenton 07-Oct-05 08:58
    Subject: Re : How to tell embedded jinitator applet is still running when window closed
    I don't know if this is exactly what you are after but you can add the following to the top of your basejini.htm file and it should prompt the user before exiting the IE window.
    <BODY %HTMLbodyAttrs%>
    %HTMLbeforeForm%
    <SCRIPT>
    <!--
    window.onbeforeunload = unloadApplet;
    function unloadApplet(){
    message = "Warning! Please exit the Java Applet prior to
    exiting the browser"
    return message;
    //-->
    </SCRIPT>
    From: Oracle, mohammed pasha 07-Oct-05 09:55
    Subject: Re : How to tell embedded jinitator applet is still running when window closed
    David,
    Well I could not understand your complete requirement.
    Refer to Note.201481.1 How to Close the Browser Window When Closing Forms And How to Simulate SeparateFrame By Javascript
    Note.115905.1 How to Close Browser Window When Closing Webforms Applet
    Kind Regards,
    Anwar
    From: David Wilton 07-Oct-05 14:37
    Subject: Re : How to tell embedded jinitator applet is still running when window closed
    Thank you for your reply and yes you did not understand my question fully.
    Sorry if this is a long reply
    I am able to close the browser window using information in notes 115905.1 and 201481.1, this is not the issue. We implemented this several years ago. It is workable for both separate frame = true or false.
    It is most important to not allow the user to end their forms application by closing the windows browser, they must close using normal form exit commands.
    What I want is to have separate frame = false, the big drawback to this option is the user can exit the application and bypass all forms code by pressing the windows "X" close button. This is why we need the code as just provided by Andrew Lenton above in this thread.
    BUT Andrew's code will always prompt the user before closing the window and I do not want that. I want the user to be prompted only under scenario 2 listed below.
    Here's the 2 case scenario for exiting the application.
    1. If the user closes properly and uses exit form which fires all normal form triggers including post_form with it's call to close.html file.
    All uncommitted changes are saved or rollback and the users session is ended normally both on the database and in the application server.
    All browser windows will close, great all is good. And without Andrew's code the window will close but with Andrew's code the user will be prompted to close or not, if they select Cancel the window will remain but the applet has already ended so why prompt? ...This is what I want to avoid.
    2. In the forms app. if the user clicks the windows "X" close button with uncommitted changes. The browser just closes the changes are rollback without prompting the user to save. The users sessions are now lost and still running in the database and application server until they are timed out.
    If I use Andrew's code then the user will be prompted to continue to close or go back, if they click Cancel to go back then focus returns to the forms application and the user can continue to work. If the user clicks OK then the window closes and unfortunately their sessions are still lost until timed out.
    So what I desire is to add to Andrew's code to check if the embedded applet is still running and prompt the user to close or not accordingly.
    Something like:
    Basejini.htm like
    </HEAD>
    <SCRIPT LANGUAGE="JavaScript">
    function maximizeWindow()
    window.moveTo(0,0);
    window.resizeTo(screen.availWidth,screen.availHeight);
    function confirm(){
    If(document.embeddedapplet.closed())
    Win.opener = self;
    win.close();
    Else if
    event.returnValue = "Closing Forms Application. OK to continue?";
    </SCRIPT>
    <BODY %HTMLbodyAttrs%, onload="maximizeWindow()", onbeforeunload="confirm()">
    %HTMLbeforeForm%
    I hope this explains my requirements.
    David
    From: Oracle, Evelene Raechel 10-Oct-05 06:45
    Subject: Re : How to tell embedded jinitator applet is still running when window closed
    Hi,
    Note.199928.1 How to Alert User on Closing Client's Browser Window in Webforms
    Regards,
    Rachel
    From: David Wilton 11-Oct-05 17:40
    Subject: Re : How to tell embedded jinitator applet is still running when window closed
    I'm sorry this is not helpful at all.
    Note 199928.1 is only an alert which does not stop the closing of the window and still displays as an alert if the user does close properly using exit form ... so why would you want to display the alert then?
    This is exaclty what I do not want and why I want to determine if the applet is still running before displaying any kind of message.
    David
    From: Oracle, Evelene Raechel 17-Oct-05 12:23
    Subject: Re : How to tell embedded jinitator applet is still running when window closed
    Closing thread.
    Thanks,

    Hello,
    I had the same issue last year - wanting to provide a warning on closing the browser, but only if the Forms session is still running. The approach I took is described below, see also the thread where I originally posted this at Closing brower window
    Hi there,I've had a similar requirement - or rather, the two conflicting requirements: to warn when the browser is being closed, but for the app to be able to close the browser without a warning being fired.
    To always provide a warning when someone (the user or the Forms app) tries to go to a different page (e.g. your close.htm), use Javascript like:
    function confirmExit(){
    if(appletRunning==true) {
    msg="Closing this window or navigating to another page will end your SomeGreatApp session.";
    window.event.returnValue=msg;
    And make a call to confirmExit() in the onBeforeUnload event of your main page.
    You'll notice I first check an 'appletRunning' variable before displaying the warning. This Javascript variable is set to true by my app when it starts up, using an embedded Javabean that calls out to Javascript. Once that variable is set to true, then the warning will be displayed if the user tries to shut the browser by clicking on the 'x' button, or to go to a different URL.
    When my app is shutting down, it uses the same Javabean to set appletRunning back to false. It then navigates to a close.htm - which will be done without a warning being displayed.
    See Re: How can a Javabean call Javascript function of the basejpi.html?? for example code on how to call Javascript from a bean embedded in your Forms app.
    Hope these ideas help you out, it's worked for me (so far, anyway!!)
    James

Maybe you are looking for

  • Problem getting arraylist values from request

    Hi All, I am trying to display the results of a search request. In the jsp page when I add a scriplet and display the code I get the values else it returns empty as true.Any help is appreciated. <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/js

  • SG300-28 VLAN`s

    I would like to swich SG300-28 grouped into separate VLAN ports. (firmware ver. 1.3.7.18)   L2 mode 1 separate vlan - Ports 1-4    - Connected to port 1 on the router DHCP1 link    - To ports 2-4 - stations that receive addresses from DHCP1 2 separat

  • Latest Flash player 11.8.800.94 does not work

    I can view youtube videos however I am unable to view certain websites. It just comes up with a black screen when loading the media. BBC Iplayer is a prime example. I have the latest flash, it is updated and has been installed and uninstalled repeate

  • How do I unsave my password from my yahoo sign in. It only started when I started using firefox

    My username and password have been saved on my yahoo account and I want to remove them but cant seem to find the way Please help

  • Schema and user management.

    Hi, I am planning to create multiple users for a particular schema. Ex: I have a schema emp_db. will it be possible to create multiple users who access the same schema. I am planning to do an audit on the schema to know which user has done the modifi