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

JEditorPane shows htm file in disorder

    XMLWordPrintable

    Details

      Description

      OPERATING SYSTEM(S)
      RHEL3 U4 and RHEL4 U1
      FULL JDK VERSION(S):
      java -version
      java version "1.5.0 04"
      Java(TM) 2 Runtime Environment. Standard Edition (build 1.5.0 04-b05)
      Java HotSpot(TM) Client VM (build 1.5.0 04-b05.mixed mode)
      DESCRIPTION:
      - Exact steps to reproduce
       1. Compile and run case 'java Browser'
       2. Input file:///[Path]/1.htm as HTML file location
       3. Click Load button, a straight line goes through the last word "Java" <--Problem
      - Minimal source code that demonstrates the problem
      ----------Browser.java code---------------
      /** Browser.java */
      import java.awt.*;
      import java.awt.event.*;
      import java.io.*;
      import java.net.*;
      import javax.swing.*;
      public class Browser extends JFrame implements ActionListener {
      private JEditorPane editor;
      private JTextField path;
      public Browser(String url) {
      super("Simple Java Browser");
      JButton load = new JButton("Load");
      load.addActionListener(this);
      load.setMnemonic('L');
      path = new JTextField(16);
      path.addActionListener(this);
      JPanel panel = new JPanel();
      panel.add(load);
      panel.add(new JLabel("Location:"));
      panel.add(path);
      getContentPane().add(panel, "North");

      try {
      editor = new JEditorPane(url);
      } catch (Exception e) {
      editor = new JEditorPane();
      //e.printStackTrace();
      }

      editor.setEditable(false);
      getContentPane().add(new JScrollPane(editor));

      setDefaultCloseOperation(EXIT_ON_CLOSE);
      setSize(500, 500);
      show();
      }

      public void actionPerformed(ActionEvent event) {
      readDocument();
      }

      public Browser() {
      this("");
      }

      private void readDocument() {
      try {
      URL url = new URL(path.getText());
      //editor.setEditable(false);
      editor.setPage(url);
      } catch (Exception e) {
      e.printStackTrace();
      }
      }

      public static void main(String[] args) {
      if (args.length == 0) {
      new Browser();
      } else {
      new Browser(args[0]);
      }
      }
      }
      ---------------------code end-----------------
      ---------------------test.htm-------------------
      <HTML>
      <HEAD>
      <META http-equiv="Content-Type" content="text/html;charset=big5">
      <TITLE></TITLE>
      </HEAD>
      <BODY>
      <H4 align="center">Index</H4>
      <P align="center">
      <A href="#LINKS">Links</A><BR>
      <A href="#HEADINGS">Headings</A><BR>
      <A href="#FONTS">Fonts</A><BR>
      <A href="#STYLES">Styles</A><BR>
      <A href="#LISTS">Lists</A><BR>
      <A href="#TABLES">Tables</A><BR>
      <A href="#IMAGES">Images</A><BR>
      <A href="#CHARACTERS">Characters</A><BR>
      <A href="#COMPONENTS">Components</A><BR>
      <A href="#JAVASCRIPT">JavaScript</A><BR>
      <A href="#JAVA">Java</A>
      <HR>
      </BODY>
      </HTML>
      ---------------------1.htm end-------------
      - Any additional configuration information
        This defect only occurs on Traditional Chinese.
        Modify the file 1.htm, remove the line "<P align="center">", the error will disappear.

        Attachments

          Activity

            People

            Assignee:
            peterz Peter Zhelezniakov
            Reporter:
            elarsen Erik Larsen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Imported:
              Indexed: