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

HTMLEditorKit.read(...) does not set href attributes.

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      swing1.1
    • CPU:
      sparc
    • OS:
      solaris_2.5.1
    • Verification:
      Verified

      Description



      Name: aaC67449 Date: 05/19/98



      HTMLEditorKit.read(...) does not set href attributes. So HTMLEditorKit.LinkController listener can not generate HiperlinkEvent.

      This bug is introduced in JDK1.2-beta4.

      ------------------Example-----------------------------------
      import java.awt.swing.text.html.*;
      import java.awt.swing.text.*;
      import java.io.*;
      public class Test {

        public static void main(String arrgv[]) {
        
           String test="<!DOCTYPE HTML PUBLIC \"-//w3c//DTD html 3.2//EN\"><HTML><HEAD><TITLE>test</TITLE></HEAD></head><body><P><A href=\"index.html\">Test</A></P></body></html>";
          
           HTMLEditorKit c= new HTMLEditorKit();
            
           Document doc = c.createDefaultDocument();
              
           try {
             c.read(new StringReader(test),doc,0); // prepare test document
             
             Element e = ((StyledDocument)doc).getCharacterElement(2);
             AttributeSet a = e.getAttributes();
             String href = (String) a.getAttribute("href");

             if (href==null)
                 System.out.println("Failed. Href attribute is null");
             else
                 System.out.println("Passed");
             
          } catch(Exception e) {
              e.printStackTrace();
          }
        }

      }
      -------------------Output------------------------------------
      Failed. Href attribute is null
       

      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            tprinzinsunw Timothy Prinzing (Inactive)
            Reporter:
            aalievsunw Artem Aliev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: