Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8015100

[macosx] Applet graphics corrupted when applet width/height exceeds screen dimensions

XMLWordPrintable

    • 2d
    • b06
    • os_x

        FULL PRODUCT VERSION :
        java version " 1.7.0_10 "
        Java(TM) SE Runtime Environment (build 1.7.0_10-b18)
        Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Darwin New-Users-MacBook-Pro.local 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64

        MacOS 10.7.5

        EXTRA RELEVANT SYSTEM CONFIGURATION :
        Mid-2009 Macbook Pro with 1440x900 display, and no external monitors

        A DESCRIPTION OF THE PROBLEM :
        When an applet is embedded in an HTML page, and the applet's width and height parameters are set to exceed the resolution of the display (e.g. you set width and height to 10000), then the applet displays gibberish instead of the expected UI or graphics.

        This has been tested and verified on Safari 6.0.2 and Firefox 18 on MacOS 10.7.5 and 10.8.2.

        This error does not occur in the Applet Viewer when the applet viewer is sized similarly. So, it seems to be only a browser/plugin-related painting problem.

        REGRESSION. Last worked in version 6u31

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Use the attached code sample. Create an HTML page that includes the applet, and whose width and height exceed the resolution of your display (as shown in the source comments). Observe that the applet displays garbage instead of the expected behaviour.

        The expected behaviour is a square sliding from left to right.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        The applet should paint normally.
        ACTUAL -
        The applet displays garbage (see http://i.imgur.com/3FnDu.png for an example).

        FWIW, the garbage appears to be the height of the applet less the height of the display. So, if:

        h = appletHeight;
        H = display height;

        garbageHeight = h - H;

        The applet *does* paint correctly below the garbageHeight.

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import javax.swing.*;
        import java.awt.*;
        import java.awt.event.ActionEvent;
        import java.awt.event.ActionListener;

        /*
        Use with an HTML file like:

            <!doctype html>
            <applet width= " 5000 " height= " 5000 " code= " TestApplet2 " archive= " applet.jar " ></applet>
         */

        public class TestApplet2 extends JApplet {
            Timer drawFrameTimer;

            @Override
            public void init() {
                drawFrameTimer = new Timer(20, new ActionListener() {
                    final Graphics2D graphics = (Graphics2D) getGraphics();
                    int frame = 1;

                    public void actionPerformed(ActionEvent e) {
                        final int currentFrame = frame;

                        graphics.setColor(Color.white);
                        graphics.fillRect(0, 0, getWidth(), getHeight());
                        graphics.setColor(Color.black);
                        graphics.fillRect(currentFrame, 100, 100, 100);

                        frame++;
                        if (frame >= getWidth()) {
                            frame = 0;
                        }
                    }
                });
            }

            @Override
            public void start() {
                drawFrameTimer.start();
            }

            @Override
            public void stop() {
                drawFrameTimer.stop();
            }
        }
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        Use an applet height and width that does not exceed the screen dimensions.

              serb Sergey Bylokhov
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: