public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) { HyperlinkEvent.EventType type = hyperlinkEvent.getEventType(); final URL url = hyperlinkEvent.getURL(); // if (type == HyperlinkEvent.EventType.ENTERED) { // Utility.debugPrintln("patterns","Entered " + url.toString()); // } else if (type == HyperlinkEvent.EventType.EXITED) { // Utility.debugPrintln("patterns","Exited"); // } if (type == HyperlinkEvent.EventType.ACTIVATED) { // Utility.debugPrintln("Activated"); Runnable runner = new Runnable() { public void run() { // Retain reference to original Document doc = editorPane.getDocument(); try { editorPane.setPage(url); } catch (IOException ioException) { JOptionPane.showMessageDialog( frame, "Error following link " + url.toString(), "GIPO Error", JOptionPane.ERROR_MESSAGE); editorPane.setDocument(doc); } } }; SwingUtilities.invokeLater(runner); } }
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; } } } }
/** Notification of a change relative to a hyperlink. */ public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { linkActivated(e.getURL()); } }
public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { getAppletContext().showDocument(e.getURL(), "_blank"); } }
/** * Method to handle hyper link events. * * @param event hyper link event */ public void hyperlinkUpdate(HyperlinkEvent event) { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { setCursor(cbusy); try { URL url = event.getURL(); int ind1 = event.getDescription().indexOf("["); int ind2 = event.getDescription().lastIndexOf("]"); String search = ""; if (ind1 > -1 && ind2 > -1) search = event.getDescription().substring(ind1 + 1, ind2); else { ind1 = event.getDescription().indexOf("=") + 1; // genedb if (ind1 > -1) search = event.getDescription().substring(ind1); } if (desktop != null) { if (BigPane.srsTabPane.isSelected()) setUpSRSFrame(url, search); if (BigPane.srsWin.isSelected()) { int hgt = (2 * desktop.getHeight()) / 3; Annotation edPane = new Annotation(url); JScrollPane jsp = new JScrollPane(edPane); JInternalFrame jif = new JInternalFrame( "SRS " + search, true, // resizable true, // closable true, // maximizable true); // iconifiable); JMenuBar menuBar = new JMenuBar(); menuBar.add(new CommonMenu(jif)); jif.setJMenuBar(menuBar); jif.getContentPane().add(jsp); jif.setLocation(0, 0); jif.setSize(800, hgt); jif.setVisible(true); desktop.add(jif); } if (BigPane.srsBrowser.isSelected()) BrowserControl.displayURL(event.getDescription()); } else { setPage(url); back.add(url); } } catch (IOException ioe) { String msg = event.getDescription(); if (msg.length() > 50) msg = msg.substring(0, 50) + "...."; JOptionPane.showMessageDialog( this, "Cannot reach URL:\n" + msg, "Cannot Connect", JOptionPane.INFORMATION_MESSAGE); // ioe.printStackTrace(); // ("Can't follow link to " + // event.getURL().toExternalForm() ); } setCursor(cdone); } else if (event.getEventType() == HyperlinkEvent.EventType.ENTERED) { try { JTextField statusField = (JTextField) BigPane.srsFrame.getContentPane().getComponent(1); statusField.setText(event.getDescription()); } catch (Exception exp) { } } else if (event.getEventType() == HyperlinkEvent.EventType.EXITED) { try { JTextField statusField = (JTextField) BigPane.srsFrame.getContentPane().getComponent(1); statusField.setText(""); } catch (Exception exp) { } } }