Details
-
Type:
Bug
-
Status: Closed
-
Priority:
P3
-
Resolution: Fixed
-
Affects Version/s: 1.2.0
-
Fix Version/s: 1.2.0
-
Component/s: client-libs
-
Labels:
-
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
======================================================================