-
Bug
-
Resolution: Unresolved
-
P3
-
None
-
6u10
-
x86
-
windows_vista
FULL PRODUCT VERSION :
java version "1.6.0_10"
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) 64-Bit Server VM (build 11.0-b15, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.0.6001]
A DESCRIPTION OF THE PROBLEM :
If a JEditorPane contains a link like "#target", clicking on it generates a HyperlinkEvent with a null URL.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the provided test program.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Should print the same anchor which is found in the HTML text.
ACTUAL -
Actually prints null.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.JEditorPane;
import javax.swing.JOptionPane;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import org.junit.Test;
public class Test {
public static void main(String[] args) {
String message = "<html><p id='target'><a href='#target'>click me</a><p></html>");
JEditorPane label = new JEditorPane("text/html", message);
label.setEditable(false);
label.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent event) {
System.out.println(event.getURL());
}
});
JOptionPane.showMessageDialog(null, label, "Click the link", JOptionPane.ERROR_MESSAGE);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
As long as you don't actually need the anchor you can just check for null before using the URL. If you need it, no idea.
java version "1.6.0_10"
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) 64-Bit Server VM (build 11.0-b15, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.0.6001]
A DESCRIPTION OF THE PROBLEM :
If a JEditorPane contains a link like "#target", clicking on it generates a HyperlinkEvent with a null URL.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the provided test program.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Should print the same anchor which is found in the HTML text.
ACTUAL -
Actually prints null.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.JEditorPane;
import javax.swing.JOptionPane;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import org.junit.Test;
public class Test {
public static void main(String[] args) {
String message = "<html><p id='target'><a href='#target'>click me</a><p></html>");
JEditorPane label = new JEditorPane("text/html", message);
label.setEditable(false);
label.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent event) {
System.out.println(event.getURL());
}
});
JOptionPane.showMessageDialog(null, label, "Click the link", JOptionPane.ERROR_MESSAGE);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
As long as you don't actually need the anchor you can just check for null before using the URL. If you need it, no idea.