United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6715783 Draggable Applet does not resize to fit into page when closed outside browser
JDK-6715783 : Draggable Applet does not resize to fit into page when closed outside browser

Details
Type:
Bug
Submit Date:
2008-06-17
Status:
Open
Updated Date:
2014-05-22
Project Name:
JDK
Resolved Date:
Component:
deploy
OS:
windows_xp
Sub-Component:
plugin
CPU:
x86
Priority:
P3
Resolution:
Unresolved
Affected Versions:
6u10
Targeted Versions:

Related Reports

Sub Tasks

Description
FULL PRODUCT VERSION :
build 1.6.0_10-beta-b25

ADDITIONAL OS VERSION INFORMATION :
Windows XP SP2

A DESCRIPTION OF THE PROBLEM :
when the applet is resized outside the browser (if it has been dragged) and closed afterwards, it is not automatically resized to fit into the provided space of the page.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. drag applet
2. resize window
3. close applet
4. check if applet fits into web page

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
applet is resized to fit into specified space on the web page
ACTUAL -
applet not automatically resized and does not fit into page

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
/*html file
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
        <p>
            <applet width="200" height="200">
                <param name="jnlp_href" value="DragExample.jnlp">
                <param name="separate_jvm" value="true">
                <param name="classloader_cache" value="false">
                <param name="draggable" value="true">
            </applet>
        </p>
    </body>
</html>

*/

/*JNLP
<?xml version="1.0" encoding="utf-8"?>
<jnlp codebase="file:/C:/nbWorkspace/AppletTest/" href="DragExample.jnlp">
    <information>
        <title>Simple Draggable Applet Example</title>
        <vendor>test</vendor>
        <homepage href="file:/C:/nbWorkspace/AppletTest/"/>
        <description kind="short">
            A simple draggable applet example showing customization of the drag gesture and close button, desktop integration, and fallback of applet services as the applet becomes disconnected.
        </description>
        <offline-allowed/>
        <shortcut online="false">
            <desktop/>
        </shortcut>
    </information>
    <resources>
        <j2se href="http://java.sun.com/products/autodl/j2se" version="1.6+"/>
        <jar href="dist/AppletTest.jar" main="true" />
    </resources>
    <!-- width&height used when relaunching from the desktop shortcut -->
    <applet-desc
      name="Drag Example"
      main-class="applet.DragExample"
      width="200"
      height="200">
    </applet-desc>
</jnlp>

*/

package applet;

import java.awt.Container;
import java.awt.Frame;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class DragExample extends javax.swing.JApplet {
    
    private ActionListener closeListener;


    /** Initializes the applet DragExample */
    @Override
    public void init() {
        try {
            java.awt.EventQueue.invokeAndWait(new Runnable() {
                public void run() {
                    initComponents();
                    label.addMouseListener(new MouseAdapter() {
                        @Override
                        public void mouseClicked(MouseEvent e) {
                            if (closeListener != null)
                                closeListener.actionPerformed(null);
                        }
                    });
                }
            });
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    
    public boolean isAppletDragStart(MouseEvent e) {
        if(e.getID() == MouseEvent.MOUSE_DRAGGED)
            return true;
        else
            return false;
    }
    
    
    public void appletDragStarted() {
        Container container = this.getParent();
        while(container != null) {
            if(container instanceof Frame) {
                Frame frame = (Frame)container;
                frame.setResizable(true);
                frame.setUndecorated(false);
                return;
            }
            container = container.getParent();
        }
    }

    

    public void setAppletCloseListener(ActionListener l) {
        closeListener = l;
    }

    public void appletRestored() {
        closeListener = null;
    }

    /** This method is called from within the init() method to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        label = new javax.swing.JLabel();

        label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        label.setText("drag me");
        label.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(label, javax.swing.GroupLayout.DEFAULT_SIZE, 362, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(label, javax.swing.GroupLayout.DEFAULT_SIZE, 241, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>


    // Variables declaration - do not modify
    private javax.swing.JLabel label;
    // End of variables declaration

}

---------- END SOURCE ----------

                                    

Comments



Hardware and Software, Engineered to Work Together