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

JTextPane is occasionally corrupted and handles entity references poorly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.0
    • client-libs



      Name: gm110360 Date: 12/13/2001


      java version "1.4.0-beta3"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b84)
      Java HotSpot(TM) Client VM (build 1.4.0-beta3-b84, mixed mode)

      If a JTextPane is used to display an HTML page, the output is sometimes
      corrupted, with following text being drawn over the top of previous text as well
      as being drawn in the correct place. The following program demonstrates the
      problem, at least when run on Linux with the fvwm2 window manager. The
      behaviour is eratic. When run with the same web page on different occasions,
      the fault appears on different lines of the output. Sometimes there is no error
      at all. Sometimes, the corruption occurs on the line commencing with "167"; on
      other occasions, the line starting with "236" is the first corrupted. The
      problem was present in 1.4.0b2 as well. This may be related to bug 4519711 but
      manifests itself in a different way.

      There is also a problem with space between an entity reference and following
      text being discarded on output, as can be seen between the European characters
      and the text that follows.

      Neither of these problems was exhibited in 1.3.1. [I should say that the font
      used is now much better than at 1.3.1, and that style is now recognized in some
      but not all situations, big improvements.]

      import javax.swing.*;
      import javax.swing.event.*;
      import javax.swing.text.*;
      import javax.swing.text.html.*;
      import java.net.*;
      import java.awt.*;
      import java.awt.event.*;
      import java.io.*;
      import java.util.*;

      public class Viewer extends JTextPane
      {
         URL current = null;

         public Viewer( String name ) throws IOException
         {
            super();
            enableEvents(AWTEvent.KEY_EVENT_MASK);

            setEditable(false);
            if (!(name == null || name.equals("")))
            {
               setURL(name);
            }
         }

         public void setURL( URL url ) throws IOException
         {
            setPage(url);
            current = url;
         }

         public void setURL( String name ) throws IOException
         {
            URL url = null;
            if (current == null) url = Viewer.class.getResource(name);
            if (url == null) url = new URL(current,name);
            setURL( url );
         }

         public static void main( String[] arg ) throws IOException
         {
            JFrame f = null;
            Viewer v = null;
            if (arg.length > 0)
            {
               f = new JFrame(arg[0]);
               v = new Viewer(arg[0]);
            }
            else
            {
               f = new JFrame("Web page");
               v = new Viewer("http://www.cs.adfa.edu.au/~gfreeman/qscharcodes.html");
            }
            Container cpane = f.getContentPane();
            JScrollPane sp = new JScrollPane(v);
            sp.setPreferredSize(new Dimension(800, 500));
            cpane.add( "Center",sp );
            f.pack();
            f.show();
         }
      }
      (Review ID: 136191)
      ======================================================================

            idk Igor Kushnirskiy (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: