JDK-6719344 : Draggable Applet does not appear in brower when closed
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 6u10
  • Priority: P3
  • Status: Closed
  • Resolution: Won't Fix
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2008-06-25
  • Updated: 2017-06-26
  • Resolved: 2017-06-26
Description
FULL PRODUCT VERSION :
java version "1.6.0_10-rc"
Java(TM) SE Runtime Environment (build 1.6.0_10-rc-b25)
Java HotSpot(TM) Client VM (build 11.0-b13, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Windows XP SP2

A DESCRIPTION OF THE PROBLEM :
Draggable Applet does not appear in the browser when closed via the X on the window title bar.

This happens only when the user moves its mouse directly after dragging to the X without moving the mouse over the applet's UI content.

In this situation  public void appletDragFinished() {} is _not called and a NPE is thrown on close.

appletDragFinished() is only called when the user moves the mouse the first time over the applet (this is always the case when frame decorations are disabled). This is probably the root cause.

try the appet on this page:
https://fishfarm.dev.java.net/demo/

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Drag applet
2. move to the X of the window title bar without(!) moving over the applets ui content
3. close via X
4. check if applet appears in browser

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
applet appears in browser
ACTUAL -
NPE is thrown instead of drag finished event, applet does not appear in browser

ERROR MESSAGES/STACK TRACES THAT OCCUR :
drag started
applet restored
drag finished
--closing--
Exception in thread "AWT-EventQueue-3" java.lang.NullPointerException
	at sun.plugin2.applet.DragHelper$PerAppletInfo.restore(Unknown Source)
	at sun.plugin2.applet.DragHelper.restore(Unknown Source)
	at sun.plugin2.main.client.PluginMain$PluginMainDragListener.appletExternalWindowClosed(Unknown Source)
	at sun.plugin2.applet.DragHelper$PerAppletInfo$CloseListener.actionPerformed(Unknown Source)
	at applet.AquariumApplet$2.windowClosed(AquariumApplet.java:108)
	at java.awt.AWTEventMulticaster.windowClosed(Unknown Source)
	at java.awt.AWTEventMulticaster.windowClosed(Unknown Source)
	at java.awt.Window.processWindowEvent(Unknown Source)
	at javax.swing.JFrame.processWindowEvent(Unknown Source)
	at java.awt.Window.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(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)


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
/*
put this into the draggable applet example
*/

public void appletDragStarted() {
        System.out.println("drag started");
        // enable default frame docoration
        Container container = this.getParent();
        while(container != null) {
            if(container instanceof Frame) {
                Frame frame = (Frame)container;
                frame.setResizable(true);
                frame.setUndecorated(false);
                frame.addWindowListener(new WindowAdapter() {
                    @Override
                    public void windowClosed(WindowEvent e) {
                        System.out.println("--closing--");
                        if(closeListener != null)
                            closeListener.actionPerformed(null);
                    }
                });
                return;
            }
            container = container.getParent();
        }
    }

    public void appletDragFinished() {
        System.out.println("drag finished");
    }
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
move mouse always over applets content or don't enable frame decorations