public void hyperlinkUpdate(HyperlinkEvent event) { HTMLDocument documentHTML = null; if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { m_sPageCourante = event.getURL().toString(); if (event instanceof HTMLFrameHyperlinkEvent) { documentHTML = (HTMLDocument) jEditorPaneHTML.getDocument(); documentHTML.processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent) event); } else ChargerPageActive(); } }
// implemented for HyperlinkListener public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { JEditorPane ep = (JEditorPane) (e.getSource()); // handle frame events properly if (e instanceof HTMLFrameHyperlinkEvent) { HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent) e; HTMLDocument doc = (HTMLDocument) (ep.getDocument()); doc.processHTMLFrameHyperlinkEvent(evt); } else // handle normal links { try { URL currentLoc = new URL(location); URL newLoc = new URL(currentLoc, e.getDescription()); setBrowserLocation(newLoc.toString()); } catch (MalformedURLException malUrl) { JOptionPane.showMessageDialog( this, "Malformed URL", "Browser Error", JOptionPane.ERROR_MESSAGE); return; } } } }