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

Displaying Animated Gif in JEditorPane causes nonstop CPU usage

XMLWordPrintable

    • tiger
    • x86
    • windows_2000, windows_xp



      Name: jk109818 Date: 02/20/2003


      FULL PRODUCT VERSION :
      java version "1.4.1_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
      Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)

      FULL OPERATING SYSTEM VERSION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      When creating a JEditorPane and displaying HTML that
      contains a refrence to an animated gif the CPU usages is
      kept at 100% after component is destoyed.

      See bug report 4215118 that gives workaround for JLabel and
      JButton.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1.Create HTML that countains ref to animated gif.
      2.Create new window that contains a JEditorPane with
      content type HTML and load HTML into it.
      3.From another window open window.
      4.Animation should display.
      4.Close window.
      5. CPU usage does not return to what expected.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      CPU 0%


      ---- BEGIN SOURCE ----

      import java.awt.*;
      import javax.swing.*;
      import java.awt.event.*;

      public class AnimatedGifBUG{


          public AnimatedGifBUG(){

      JFrame frame = new JFrame();

      JButton button = new JButton("Press me!");

      button.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e){
      for(int i = 0 ; i<5;i++){
      showDialog(i);
      }

      }

      });
      frame.getContentPane().add(button);
      frame.setSize(600,400);
      frame.show();


          }


          public static void main(String args[]){

      new AnimatedGifBUG();

          }

          
          private void showDialog(int i ){
      final JDialog dialog = new JDialog();

      JEditorPane pane = new JEditorPane();

      JButton button = new JButton("Close");

      button.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e){
      dialog.dispose();

      }

      });


      pane.setContentType("text/html");
      pane.setText("<img src=\"file://c:/webbugs/animation"+i+".gif\">");
      dialog.getContentPane().add(pane,BorderLayout.CENTER);
      dialog.getContentPane().add(button,BorderLayout.SOUTH);
      dialog.setSize(600,500);

      dialog.show();


          }

      }


      ---- END SOURCE ----

      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER WORKAROUND :
      See bug report 4215118
      (Review ID: 180813)
      ======================================================================

            naasunw Naa Naa (Inactive)
            jkimsunw Jeffrey Kim (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: