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.

Similar Messages

  • How to close child windows when parent window closed in jsp

    how to close child windows when parent window closed in jsp
    becoz it can't be able to recognise it's parent
    with the whole application
    plz send me some sample code of it

    Hi, I have no idea how to do this is JSP.
    However createing a modal window (with javascript) would mean that the user can not use the parent window untill he closes the child window. However not sure if this is what you are searching.
    Otherwise you can detect the onClose (I think) and close the window from there.
    However both the above are JavaScript and not JSP.
    rwgards,
    sim085

  • How to trap applet window closing event?

    Hi all,
    I would like to know how could one trap the event of the browser window containing an applet being closed by the user?
    Thank you,

    Hi. this would be useful to me too.
    Trouble is, I'm not sure that you can. applet.stop( )
    and applet.destroy( ) might be called, but there is
    no guarentee that you can complete processing before
    you are terminated, especially if you need to do
    something slow, like returning state data to your
    server. And you can't stop the broswer closing.
    I know that in Javascript, you can catch and even
    stop the browser window being closed, which is how
    things like goggledocs can ask for confirmation
    before closing. (window.onbeforeunload( ) ).
    I have toyed with the idea of having a
    javascript/ajax thread in my html, to catch this
    termination, and communicate back to the server from
    java to say a document has changed, but it all seems
    rather heavyweight for such a simple task.Look at Runtime.addShutdownHook()
    You could also try using a WindowListener as well and trap the WindowClose Event.
    stop() should do very little other than invalidate the current thread/run flags
    and then exit. ie: a stop() example
    public void stop()
    task = null;
    or
    public void stop()
    running = false;
    Your run method should look for a stop condition and then exit.
    Otherwise you could be doing stop processing while run is still
    running.
    (T)

  • Null Pointer exception when reloading window

    Hi, I have a window that uses a util Timer and it works fine while the window is open. After closing the window with DISPOSE_ON_CLOSE and then re-opening the window I always get a NullPointer exception on my Timer. Can anybody explain why and/or a way around this?

    Hi, I have a window that uses a util Timer and it
    works fine while the window is open. After closing
    the window with DISPOSE_ON_CLOSE and then re-opening
    the window I always get a NullPointer exception on my
    Timer. Can anybody explain why and/or a way around
    this?Seriously? Honestly? What on earth do you think dispose means??

  • IE locks out after applet window closed

    I am using an applet which communicates with the server through RMI.
    I am launching a browser window with my applet in it from a secure socket layer server.
    When I close this window IE locks out but Netscape doesn't.
    I tried overriding Applet.destroy() in order to dispose() any windows which I make using the browser frame and which might still be hanging around.
    I notice that Netscape calls Applet.destroy() but IE doesn't or does not get that far.
    Please can anyone tell me if I am on the right track and/or what I might try to fix this lockout.
    Thanks,
    Nick

    Hi,
    I have a similar problem. From watching he trace file of the Java plug-in, IE 5.50.4134.0600 is calling the STOP, DESTROY, DISPOSE, and QUIT applet events all together. It doesn't wait for the applet.stop and applet.distroy functions to finish. My applet saves the user settings in serialized objects and sends it to the server to be saved in the database. If this process finishes before the shutdown of IE, it goes through to the server. Unfortunately, it's not always that fast.
    My applet is not signed. That means that any restricted call in applet.stop() and applet.distroy() will be restricted because they are not called from inside the sand box. I read somewhere that signing the applet will solve this. However, Is that the cause of my problem?
    Thanks,
    BYTTNerd

  • How to terminate an app when last window closed?

    it is driving me nuts, i am doing an xcode projetct: an
    applescript cocoa application.
    so far so good, but:
    how can i terminate the application, when the last window
    is closed??
    i have read anything about ApplicationShouldTerminate...... methods
    and any obj C method that could have something to do with this topic,
    but how can i do this operation in an applescript application?
    thanks
    Derand

    There are several application delegate methods that can be added your AppDelegate.applescript (see NSApplicationDelegate Protocol Reference) - the one you are looking for is applicationShouldTerminateAfterLastWindowClosed:, for example
    on applicationShouldTerminateAfterLastWindowClosed_(sender)
           return true
    end applicationShouldTerminateAfterLastWindowClosed_

  • Applet window closing problem

    hi all,
    I am in need of some guidance, my program uses a GUI but i have a problem in that when the user clicks the window close button at the top right of the screen i need to execute some code but i am unable to do so, have i got the correct method? :o(
    public boolean handleEvent (Event e)
        boolean value = false;
        if ((e.target == this) && (e.id == Event.WINDOW_DESTROY))
          if (listener != null)
           //here i would like to execute some code before setting the boolean variable
            value = true;
          else
             value = false;
        return value;
      }//end handle event()

    Good day,
    As far as I'm concered, the "handleEvent (Event e)" has been deprecated and "processEvent(AWTEvent event)" should be used instead since JDK 1.1.
    I have an occurance of that "handleEvent" thing that I would like to "convert" to "processEvent", however I'm having problems with that.
    The first, which is simple, is to remove the true/false on the return statement of the handler. "handleEvent()" returns a boolean, whereas "processEvent()" returns nothing.
    When I try to get the value of the "event.id" or "event.target", the compiler claims that the information is protected.
    Can someone be nice enough to provide a code snippet to ease the transition between the "handleEvent()" and "processEvent()" things ?
    Best regards.

  • I have activated the code but when the window closed. now I can not re- enter the code to download . how do I download it now?

    Hi, can you help me? I'm student at Deltion College in the Netherlands in Zwolle. This morning I tried to activate my instalation code. I activate my code but I was shocked by the fact that I had to provide my bank details and have closed the window. Now I try to re- activate my code glands adobe cloud ( illustrator, photoshop) to install on my laptop but it will not work because the code has already been used once .

    Contact support by web chat.
    Mylenium

  • 10.8 makes iChat sleep when buddy window closed

    If I close all the iChat windows, the application essentially sleeps making it impossible to see cameras avaiable to initiate a vieo chat.  Is there any workaround?

    Hi,
    So you want to run iChat with Buddy lists closed (Hidden) ?
    And you want to Start Video Chats with people that have cameras ?
    Do you have the Menu Bar icon enabled ?
    See the Messages > Preferences > General section (Show Status in Menu Bar)
    This will provide a drop down and Buddies and show which have cameras.
    12:55 PM      Friday; July 27, 2012
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
      iMac 2.5Ghz 5i 2011 (Lion 10.7.2)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • Which of the 6 download options is the correct one for elements 11 when running windows 7 64bit.

    There are 6 options available to download but no clear instructions as to which one to downlaod. Which one is correct?

    Where are you trying to download Elements 11 from? Go to http://www.adobe.com/downloads/ and select the relevant product(Photoshop or Premiere Elements) and click on the the download link.
    Thanks
    Nikhil

  • Safari crash when window closed

    Like the post earlier, safari crashes when a window closed. I used to have Speed Download, however, it is no longer on my system, and when i searched for it (and permutations of it I found nothing.
    I tried looking in the crash log, but I dont know what Im looking for.
    I would appreciate any further suggestions.
    Thanks

    Hello Illan Wall and welcome to discussions,
    Speed Down Load MUST be removed by using their own un-installer package that comes with it.
    Did you do that or did you just trash the Application?
    Hope that helps some
    Regards
    Ian

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

  • 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

  • How do I open a photo in Elements 11 when I cannot drag it from Windows Fax Viewer? [was:Help]

    How do I open a photo in Elements 11 when I cannot drag it to photoshop, such as when I am viewing it in Windows fax viewer.

      From the Lightroom Library click Edit >> Preferences >> External Editing
    Make sure you are linking to the application and not a shortcut.
    Windows:
    Mac:

  • JComboBox shows "Java Applet Window" as last element

    Hey all,
    I am having a problem with using JComboBox. When I use JComboBox and show it in a JDialog (popup window), the last element of the drop down (JComboBox) is "Java Applet Window". This element is, however, not selectable. I want to get rid fo the "Java Applet Window" in my dropdown.
    This problem only happens when my applet opens up a JDialog that has the JComboBox, but does not happen when I add the JComboBox directly to the applet.
    I've read around in other forums that this has to do with security. I understand the need to show that a popup window (JDialog) is an applet window so the user doesn't mistake it as one of the native windows. But, the JComboBox is not a whole 'nother window, so why does it feel the needs to add that last line to designate it as a "Java Applet Window?"
    Thanks.
    Nina.

    My apologies, I did not clarify myself in my question. Sorry that I created misunderstandings of the problem - as evident in the response in the previous post from himanshug.
    I am using JDK 1.3.1
    I must use an applet, but all my components are standalone. They can be ran as a standalone application. But for deployment, we are using applets. It's easier to do applets so clients can access via browser than deploy a whole application installation on 50 machines halfway across the world.
    And no, there is no element in my list that says "Java Applet Window". When running my application standalone, the "Java Applet Window" does not appear as the last element in my drop down.
    The "Java Applet Window" also does NOT appear when I add the drop down directly to the applet. It only appears when the drop down is in a JDialog that gets launched by an applet.
    My problem: How to get rid of the "Java Applet Window" as it seems something is adding this to my dropdown. And it's not my code that is adding it.
    Thanks. I am also up'ing the duke dollars for a solution to this to 15.

Maybe you are looking for