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

HTML-OBJECT-Tag doesn't work correctly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.2.1
    • client-libs
    • beta
    • generic
    • generic



      Name: rlT66838 Date: 06/18/99


      When I use
      <object classid="MyClass"></object>
      in a HTML-File and load it with the JEditorPane, my own
      class was not loaded. When I use any Swing-Class, like this
      in the API (javax.swing.JLabel), it works.
      The same HTML-File and the same "MyClass" work together
      perfectly when using JDK1.1.6 and Swing1.1.1b2!

        - Exact steps to reproduce the problem.

      Compile the attached sources and do:
      java HTMLSunBugReports
      in the directory HTMLSunBugReports.

      As you'll see, the primitive MyJLabel won't be displayed.
      JLabel and JTextField will be displayed without any problems.


           - The exact text of any error message(s) that appeared.

      There're none, because javax.swing.text.html.ObjectView catches
      Throwable :-(

         - Any trace information.

      None.

      I tested JDK1.2.1 on Solaris 2.6 and WinNT with the same results.
      You should be able to reporduce the problem very easily.

      cat HTMLSunBugReports.java
      import java.io.*;
      import java.net.*;
      import javax.swing.*;
      import javax.swing.event.*;
      import javax.swing.text.*;
      import javax.swing.text.html.*;

      public class HTMLSunBugReports implements DocumentListener {

        public HTMLSunBugReports () {
          JFrame f = new JFrame("HTML-Bug in JDK1.2.1");
          URL pageURL = null;
          JEditorPane htmlDisplay = new JEditorPane();
          try {
            pageURL = new URL( "file:./test.html" );
          } catch (MalformedURLException mue) {
            System.err.println( "Attempted to open example.html "
                                + "with a bad URL: "
                                + pageURL );
          }
          
          try {
            htmlDisplay.setPage(pageURL);
          } catch(IOException ioe) {
            System.err.println("IOException while opening HTML page!");
          }
          htmlDisplay.setEditable(false);
          htmlDisplay.getDocument().addDocumentListener(this);
          f.getContentPane().add("Center", htmlDisplay);
          f.setSize(600, 400);
          f.validate();
          f.show();
        }

          
        public void insertUpdate(DocumentEvent e) {
          System.out.println("insertUpdate!");
        }
          
        public void removeUpdate(DocumentEvent e) {
          System.out.println("removeUpdate!");
        }

        public void changedUpdate(DocumentEvent e) {
          System.out.println("changedUpdate!");
        }

        public static void main(String args[]) {
          new HTMLSunBugReports();
        }
        
      }

      MyJLabel.java
      import javax.swing.JLabel;

      public class MyJLabel extends JLabel {
      }

      test.html
      <html>
        <head>
          <title>Test-Maske</title>
        </head>

        <body text="#000000" bgcolor="#C0C0C0" link="#3333FF" vlink="#551A8B" alink="#FF0000">

          <h1 align="center"><font size="5"><strong>Enter something</strong></font></h1>
          <p>&nbsp;</p>

          <form method="get" name="person" action="">
            <table border="1" width="100%">
              <tr>
         <td>
           <select size=1 name="salutation">
             <option selected>Mr.</option>
             <option>Ms.</option>
           </select>
           Name:
         </td>
                <td width="40%"><input type="text" size="20" name="name"></td>
                <td>Firstname:</td>
                <td width="40%"><input type="text" size="20" name="firstname"></td>
              </tr>
              <tr>
                <td>Voice phone:</td>
                <td width="40%"><input type="text" size="20" name="phone"></td>
                <td>Fax:</td>
                <td width="40%"><input type="text" size="20" name="fax"></td>
              </tr>
            </table>
            <p align="center">
       <input type="submit" name="ok" value="Confirm">
       <input type="reset" name="cancel" value="Cancel">
       <input type="submit" name="delete" value="Delete">
            </p>
          </form>

          <object classid="javax.swing.JLabel">
            <param name="text" value="sample text">
          </object>
          
          <object classid="MyJLabel">
            <param name="text" value="sample text">
          </object>
          
         <object classid="javax.swing.JTextField">
            <param name="text" value="sample text">
          </object>
          
        </body>

      </html>

      (Review ID: 84405)
      ======================================================================
      Aditional information from user

      Are you
      still able to reproduce this problem and if so can you provide me with the

      Yes, I've reproduced this bug right know with JDK1.2.2(release) on WinNT

      following information:
      > Output of Java -fullversion

      P:\>java -version
      java version "1.2.2"
      Classic VM (build JDK-1.2.2-W, native threads, symcjit)

      P:\>java -fullversion
      java full version "JDK-1.2.2-W"

      > - does this occur only on 1.1.6?

      I cannot say, if it works with 1.1.6, but I can say, it works with
      1.1.8 and Swing 1.1.1b2 (I didn't check 1.1.8 with Swing 1.1.1release)


      NT4 with SP5 (german!)

      > and any other information that you might feel is relevant.

      I reattach the sample I've currently tested.
      For starting I entered: java -cp html.jar htmltest.HTMLSunBugReports
      in a directory, containing html.jar and test.html.

      I checked the sample I sent you in the previous message without
      recompiling on jdk1.1.8 with Swing 1.1.1 and: it worked!
      Veeeery strange, isn't it?

      roger.lewis@eng 1999-08-09
      ======================================================================

            svioletsunw Scott Violet (Inactive)
            rlewis Roger Lewis (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: