List of usage examples for javax.swing.event HyperlinkEvent getEventType
public EventType getEventType()
From source file:net.andydvorak.intellij.lessc.ui.notifier.NotificationListenerImpl.java
private boolean isSupportedEvent(@NotNull HyperlinkEvent event) { return !myProject.isDisposed() && event.getEventType() == HyperlinkEvent.EventType.ACTIVATED; }
From source file:com.igormaznitsa.zxpoly.ui.AboutDialog.java
public AboutDialog(final java.awt.Frame parent) { super(parent, true); initComponents();/*from www .j a v a2s .c om*/ this.editorPane.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(final HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try { Desktop.getDesktop().browse(e.getURL().toURI()); } catch (Exception ex) { } } else if (e.getEventType() == HyperlinkEvent.EventType.ENTERED) { editorPane.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else if (e.getEventType() == HyperlinkEvent.EventType.EXITED) { editorPane.setCursor(Cursor.getDefaultCursor()); } } }); this.editorPane.setContentType("text/html"); try { final String htmlText = IOUtils.toString(openAboutResource("index.html"), "UTF-8"); this.editorPane.setText(htmlText); } catch (Exception ex) { ex.printStackTrace(); } setLocationRelativeTo(parent); }
From source file:MiniBrowser.java
public void hyperlinkUpdate(HyperlinkEvent event) { HyperlinkEvent.EventType eventType = event.getEventType(); if (eventType == HyperlinkEvent.EventType.ACTIVATED) { if (event instanceof HTMLFrameHyperlinkEvent) { HTMLFrameHyperlinkEvent linkEvent = (HTMLFrameHyperlinkEvent) event; HTMLDocument document = (HTMLDocument) displayEditorPane.getDocument(); document.processHTMLFrameHyperlinkEvent(linkEvent); } else {/*from w w w .ja va2 s . c o m*/ showPage(event.getURL(), true); } } }
From source file:SimpleHelp.java
/** * Notification of a change relative to a hyperlink. From: * java.swing.event.HyperlinkListener/*from ww w . j a va2 s .c om*/ */ public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { URL target = e.getURL(); // System.out.println("linkto: " + target); // Get the help panel's cursor and the wait cursor Cursor oldCursor = help.getCursor(); Cursor waitCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR); help.setCursor(waitCursor); // Now arrange for the page to get loaded asynchronously, // and the cursor to be set back to what it was. SwingUtilities.invokeLater(new PageLoader(target, oldCursor)); } }
From source file:EditorPaneTest.java
public EditorPaneFrame() { setTitle("EditorPaneTest"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); final Stack<String> urlStack = new Stack<String>(); final JEditorPane editorPane = new JEditorPane(); final JTextField url = new JTextField(30); // set up hyperlink listener editorPane.setEditable(false);//from ww w .j a v a2 s. c o m editorPane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent event) { if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try { // remember URL for back button urlStack.push(event.getURL().toString()); // show URL in text field url.setText(event.getURL().toString()); editorPane.setPage(event.getURL()); } catch (IOException e) { editorPane.setText("Exception: " + e); } } } }); // set up checkbox for toggling edit mode final JCheckBox editable = new JCheckBox(); editable.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { editorPane.setEditable(editable.isSelected()); } }); // set up load button for loading URL ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent event) { try { // remember URL for back button urlStack.push(url.getText()); editorPane.setPage(url.getText()); } catch (IOException e) { editorPane.setText("Exception: " + e); } } }; JButton loadButton = new JButton("Load"); loadButton.addActionListener(listener); url.addActionListener(listener); // set up back button and button action JButton backButton = new JButton("Back"); backButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { if (urlStack.size() <= 1) return; try { // get URL from back button urlStack.pop(); // show URL in text field String urlString = urlStack.peek(); url.setText(urlString); editorPane.setPage(urlString); } catch (IOException e) { editorPane.setText("Exception: " + e); } } }); add(new JScrollPane(editorPane), BorderLayout.CENTER); // put all control components in a panel JPanel panel = new JPanel(); panel.add(new JLabel("URL")); panel.add(url); panel.add(loadButton); panel.add(backButton); panel.add(new JLabel("Editable")); panel.add(editable); add(panel, BorderLayout.SOUTH); }
From source file:com.android.tools.swing.ui.NavigationComponent.java
public NavigationComponent() { setEditable(false);//from w w w . java2s. c o m setContentType(ContentType.TEXT_HTML.getMimeType()); putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); // Disable links decoration. ((HTMLDocument) getDocument()).getStyleSheet().addRule("a { text-decoration:none; }"); addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) { return; } int idx = Integer.parseInt(e.getDescription()); final T item = myItemStack.get(idx); for (final ItemListener<T> listener : myItemListeners) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { listener.itemSelected(item); } }); } } }); }
From source file:net.sf.taverna.t2.workbench.ui.credentialmanager.WarnUserAboutJCEPolicyDialog.java
private void initComponents() { // Base font for all components on the form Font baseFont = new JLabel("base font").getFont().deriveFont(11f); // Message saying that updates are available JPanel messagePanel = new JPanel(new BorderLayout()); messagePanel.setBorder(new CompoundBorder(new EmptyBorder(10, 10, 10, 10), new EtchedBorder(LOWERED))); JEditorPane message = new JEditorPane(); message.setEditable(false);//from w w w . j ava2 s. co m message.setBackground(this.getBackground()); message.setFocusable(false); HTMLEditorKit kit = new HTMLEditorKit(); message.setEditorKit(kit); StyleSheet styleSheet = kit.getStyleSheet(); //styleSheet.addRule("body {font-family:"+baseFont.getFamily()+"; font-size:"+baseFont.getSize()+";}"); // base font looks bigger when rendered as HTML styleSheet.addRule("body {font-family:" + baseFont.getFamily() + "; font-size:10px;}"); Document doc = kit.createDefaultDocument(); message.setDocument(doc); message.setText( "<html><body>In order for Taverna's security features to function properly - you need to install<br>" + "'Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy'. <br><br>" + "If you do not already have it, for <b>Java 6</b> you can get it from:<br>" + "<a href=\"http://www.oracle.com/technetwork/java/javase/downloads/index.html\">http://www.oracle.com/technetwork/java/javase/downloads/index.html</a><br<br>" + "Installation instructions are contained in the bundle you download." + "</body><html>"); message.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent he) { HyperlinkEvent.EventType type = he.getEventType(); if (type == ACTIVATED) // Open a Web browser try { getDesktop().browse(he.getURL().toURI()); // BrowserLauncher launcher = new BrowserLauncher(); // launcher.openURLinBrowser(he.getURL().toString()); } catch (Exception ex) { logger.error("Failed to launch browser to fetch JCE " + he.getURL()); } } }); message.setBorder(new EmptyBorder(5, 5, 5, 5)); messagePanel.add(message, CENTER); doNotWarnMeAgainCheckBox = new JCheckBox("Do not warn me again"); doNotWarnMeAgainCheckBox.setFont(baseFont.deriveFont(12f)); messagePanel.add(doNotWarnMeAgainCheckBox, SOUTH); // Buttons JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); JButton okButton = new JButton("OK"); okButton.setFont(baseFont); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { okPressed(); } }); buttonsPanel.add(okButton); getContentPane().setLayout(new BorderLayout()); getContentPane().add(messagePanel, CENTER); getContentPane().add(buttonsPanel, SOUTH); pack(); setResizable(false); // Center the dialog on the screen (we do not have the parent) Dimension dimension = getToolkit().getScreenSize(); Rectangle abounds = getBounds(); setLocation((dimension.width - abounds.width) / 2, (dimension.height - abounds.height) / 2); setSize(getPreferredSize()); }
From source file:net.sf.jabref.gui.help.HelpContent.java
public HelpContent(JabRefPreferences prefs_) { super();/* www . j a va 2s . c om*/ pane = new JScrollPane(this, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); pane.setDoubleBuffered(true); prefs = prefs_; history = new Stack<>(); forw = new Stack<>(); setEditorKitForContentType("text/html", new MyEditorKit()); setContentType("text/html"); setText(""); setEditable(false); addHyperlinkListener(new HyperlinkListener() { private boolean lastStatusUpdateWasALink = false; @Override public void hyperlinkUpdate(HyperlinkEvent e) { String link = e.getDescription(); if (e.getEventType() == HyperlinkEvent.EventType.ENTERED) { // show the link in the status bar - similar to Firefox behavior JabRef.jrf.setStatus(link); lastStatusUpdateWasALink = true; } else { if (lastStatusUpdateWasALink) { // remove the link from the status bar JabRef.jrf.setStatus(""); lastStatusUpdateWasALink = false; } } } }); }
From source file:eu.delving.sip.frames.OutputFrame.java
public OutputFrame(final SipModel sipModel) { super(Which.OUTPUT, sipModel, "Output"); htmlPanel = new HtmlPanel("Link Checks").addHyperlinkListener(new HyperlinkListener() { @Override/* w ww . j a v a2 s .co m*/ public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) SwingHelper.launchURL(e.getURL().toString()); } }); sipModel.getRecordCompileModel().setEnabled(false); sipModel.getRecordCompileModel().addListener(new MappingCompileModel.Listener() { @Override public void stateChanged(CompileState state) { } @Override public void codeCompiled(MappingCompileModel.Type type, String code) { } @Override public void mappingComplete(MappingResult mappingResult) { try { LinkCheckExtractor extractor = new LinkCheckExtractor( mappingResult.getRecDefTree().getRecDef().fieldMarkers, new XPathContext(mappingResult.getRecDefTree().getRecDef().namespaces)); final List<String> checkLines = extractor.getChecks(mappingResult); DataSet dataSet = sipModel.getDataSetModel().getDataSet(); String prefix = sipModel.getMappingModel().getPrefix(); final LinkChecker linkChecker = new LinkChecker(httpClient); ResultLinkChecks checks = new ResultLinkChecks(dataSet, prefix, linkChecker); Work.DataSetPrefixWork work = checks.checkLinks(mappingResult.getLocalId(), checkLines, sipModel.getFeedback(), new Swing() { @Override public void run() { StringBuilder out = new StringBuilder(); ResultLinkChecks.validLinesToHTML(checkLines, linkChecker, out); htmlPanel.setHtml(out.toString()); } }); if (work != null) { sipModel.exec(work); } } catch (XPathExpressionException e) { sipModel.getFeedback().alert("XPath problem", e); } } }); }
From source file:com.hp.alm.ali.idea.content.settings.SettingsPanel.java
public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) { if (hyperlinkEvent.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { if (hyperlinkEvent.getDescription().equals("project")) { ShowSettingsUtil.getInstance().showSettingsDialog(prj, AliProjectConfigurable.DISPLAY_NAME); } else {//from w w w. java2 s. c o m ShowSettingsUtil.getInstance().showSettingsDialog(null, AliConfigurable.DISPLAY_NAME); } } }