harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Linbin Yu (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-4690) Anchor tag of HTML works incorrectly in Harmony
Date Wed, 29 Aug 2007 02:33:30 GMT
Anchor tag of HTML works incorrectly in Harmony
-----------------------------------------------

                 Key: HARMONY-4690
                 URL: https://issues.apache.org/jira/browse/HARMONY-4690
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
         Environment: Win32
            Reporter: Linbin Yu
            Priority: Minor


The following test demonstrates the problem:

import java.awt.Container;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLFrameHyperlinkEvent;

public class AnchorDemo extends JFrame implements HyperlinkListener {
	public static void main(String argv[]) {
		new AnchorDemo();
	}

	public AnchorDemo() {
		JEditorPane editorPane = new JEditorPane("text/html",
		"<a name=\"a1\">top</a><br><br><br><br><br><br>"
		+ "<a href=\"#a2\">link to bottom</a><br><br><br><br>"
		+ "<a name=\"a2\">bottom</a><br><br><br><br><br>");
		editorPane.setEditable(false);
		editorPane.addHyperlinkListener(this);
		Container container = getContentPane();
		container.add(new JScrollPane(editorPane));
		setSize(150, 150);
		setVisible(true);
	}

	public void hyperlinkUpdate(HyperlinkEvent e) {
		if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
			JEditorPane pane = (JEditorPane) e.getSource();
			HTMLDocument doc = (HTMLDocument) pane.getDocument();
			if (e instanceof HTMLFrameHyperlinkEvent) {
				HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent) e;
				doc.processHTMLFrameHyperlinkEvent(evt);
			} else {
				try {
					pane.scrollToReference("a2");
				} catch (Throwable t) {
					t.printStackTrace();
				}
			}
		}
	}
}


The attached screenshots demonstrate the behavior of Harmony and RI after clicking the hyperlink
"link to bottom".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message