/*
* HyperlinkAdapter.java
*
* Created on 15 novembre 2007, 03:25
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package net.sf.jiga.xtended.ui;
import javax.swing.JEditorPane;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLFrameHyperlinkEvent;
/**
* An HyperlinkAdpater to navigate through the Readme files and other about boxes.
* @author www.b23prodtm.info
*/
public class HyperlinkAdapter implements HyperlinkListener{
/** Creates a new instance*/
public HyperlinkAdapter() {
}
/** makes the hyperlink to actually flip the web-page
@param e the HyperlinkEvent sent by the browser when the user clicked */
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
JEditorPane pane = (JEditorPane) e.getSource();
if (e instanceof HTMLFrameHyperlinkEvent) {
HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent) e;
HTMLDocument doc = (HTMLDocument) pane.getDocument();
doc.processHTMLFrameHyperlinkEvent(evt);
} else {
try {
pane.setPage(e.getURL());
} catch (Throwable t) {
t.printStackTrace();
}
}
}
}
}