当前位置: 首页>>代码示例>>Java>>正文


Java HyperlinkListener类代码示例

本文整理汇总了Java中javax.swing.event.HyperlinkListener的典型用法代码示例。如果您正苦于以下问题:Java HyperlinkListener类的具体用法?Java HyperlinkListener怎么用?Java HyperlinkListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HyperlinkListener类属于javax.swing.event包,在下文中一共展示了HyperlinkListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createHyperlinkListener

import javax.swing.event.HyperlinkListener; //导入依赖的package包/类
public static HyperlinkListener createHyperlinkListener() {
    return new HyperlinkListener() {

        public void hyperlinkUpdate(HyperlinkEvent hlevt) {
            if (HyperlinkEvent.EventType.ACTIVATED == hlevt.getEventType()) {
                final URL url = hlevt.getURL();
                if (url != null) {
                    try {
                        openBrowser(url.toURI());
                    } catch (URISyntaxException e) {
                        LogManager.log(e);
                    }
                }
            }
        }
    };
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:BrowserUtils.java

示例2: setupPane

import javax.swing.event.HyperlinkListener; //导入依赖的package包/类
public void setupPane(JTextPane pane, final File[] files, String fileNames, final File projectDir, final String url, final String revision) {
     String msg = revision == null
             ? NbBundle.getMessage(NotificationsManager.class, "MSG_NotificationBubble_DeleteDescription", fileNames, CMD_DIFF) //NOI18N
             : NbBundle.getMessage(NotificationsManager.class, "MSG_NotificationBubble_Description", fileNames, url, CMD_DIFF); //NOI18N
    pane.setText(msg);

    pane.addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
                if(CMD_DIFF.equals(e.getDescription())) {
                    Context ctx = new Context(files);
                    DiffAction.diff(ctx, Setup.DIFFTYPE_REMOTE, NbBundle.getMessage(NotificationsManager.class, "LBL_Remote_Changes", projectDir.getName()), false); //NOI18N
                } else if (revision != null) {
                    try {
                        SearchHistoryAction.openSearch(new SVNUrl(url), projectDir, Long.parseLong(revision));
                    } catch (MalformedURLException ex) {
                        LOG.log(Level.WARNING, null, ex);
                    }
                }
            }
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:NotificationsManager.java

示例3: createInfoPanel

import javax.swing.event.HyperlinkListener; //导入依赖的package包/类
private static JTextPane createInfoPanel(String notification) {
    JTextPane balloon = new JTextPane();
    balloon.setContentType("text/html");
    String text = getDetails(notification).replaceAll("(\r\n|\n|\r)", "<br>");
    balloon.setText(text);
    balloon.setOpaque(false);
    balloon.setEditable(false);
    balloon.setBorder(new EmptyBorder(0, 0, 0, 0));


    if (UIManager.getLookAndFeel().getID().equals("Nimbus")) {
        //#134837
        //http://forums.java.net/jive/thread.jspa?messageID=283882
        balloon.setBackground(new Color(0, 0, 0, 0));
    }

    balloon.addHyperlinkListener(new HyperlinkListener() {

        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
                URLDisplayer.getDefault().showURL(e.getURL());
            }
        }
    });
    return balloon;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ShowNotifications.java

示例4: FixedWidthEditorPane

import javax.swing.event.HyperlinkListener; //导入依赖的package包/类
/**
 * Creates a pane with the given rootlessHTML as text with the given width.
 *
 * @param width
 *            the desired width
 * @param rootlessHTML
 *            the text, can contain hyperlinks that will be clickable
 */
public FixedWidthEditorPane(int width, String rootlessHTML) {
	super("text/html", "");
	this.width = width;
	this.rootlessHTML = rootlessHTML;
	updateLabel();

	setEditable(false);
	setFocusable(false);
	installDefaultStylesheet();
	addHyperlinkListener(new HyperlinkListener() {

		@Override
		public void hyperlinkUpdate(HyperlinkEvent e) {
			if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
				RMUrlHandler.handleUrl(e.getDescription());
			}
		}
	});

}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:29,代码来源:FixedWidthEditorPane.java

示例5: init

import javax.swing.event.HyperlinkListener; //导入依赖的package包/类
/**
 * Initialize this component
 */
private void init() {
	antiAliasing = false;
	// By default disable editing
	setEditable(false);
	setContentType("text/html");

	// Adds hyperlink listener
	this.addHyperlinkListener(new HyperlinkListener() {
		public void hyperlinkUpdate(HyperlinkEvent e) {
			if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
				// An hyperlink is activated
				if (getPage() != null && e.getURL().getPath() != null && e.getURL().getPath().equals(getPage().getPath())) {
					setURL(e.getURL());
				} else {
					// Open external links in default browser
					BrowserLauncher.openURL(e.getURL().toString());
				}
			}
		}
	});
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:25,代码来源:HtmlPanel.java

示例6: init

import javax.swing.event.HyperlinkListener; //导入依赖的package包/类
/**
 * Initialize this component
 */
private void init() {
	antiAliasing = false;
	// By default disable editing
	setEditable(false);
	setContentType("text/html");

	// Adds hyperlink listener
	this.addHyperlinkListener(new HyperlinkListener() {
		public void hyperlinkUpdate(HyperlinkEvent e) {
			if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
				// An hyperlink is activated
				if (getPage() != null && e.getURL().getPath() != null && e.getURL().getPath().equals(getPage().getPath())) {
					setURL(e.getURL());
				} else {
					// Open external links in default browser
					BareBonesBrowserLaunch.openURL(e.getURL().toString());
				}
			}
		}
	});
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:25,代码来源:HtmlPanel.java

示例7: JTextPaneTableCellRenderer

import javax.swing.event.HyperlinkListener; //导入依赖的package包/类
public JTextPaneTableCellRenderer() {
  textPane.setContentType("text/html");
  textPane.setEditable(false);
  textPane.setOpaque(true);
  textPane.setBorder(null);

  textPane.setForeground(UIManager.getColor("Table.selectionForeground"));
  textPane.setBackground(UIManager.getColor("Table.selectionBackground"));

  Font font = UIManager.getFont("Label.font");
  String bodyRule =
      "body { font-family: " + font.getFamily() + "; " + "font-size: "
          + font.getSize() + "pt; "
          + (font.isBold() ? "font-weight: bold;" : "") + "}";
  ((HTMLDocument)textPane.getDocument()).getStyleSheet().addRule(bodyRule);

  textPane.addHyperlinkListener(new HyperlinkListener() {

    @Override
    public void hyperlinkUpdate(HyperlinkEvent e) {
      if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
          MainFrame.getInstance().showHelpFrame(e.getURL().toString(), "CREOLE Plugin Manager");
    }
  });
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:26,代码来源:JTextPaneTableCellRenderer.java

示例8: createComponent

import javax.swing.event.HyperlinkListener; //导入依赖的package包/类
@Override
public JComponent createComponent() {
    pane.addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == EventType.ACTIVATED) {
                location = e.getURL().toExternalForm();
                openLocation();
            }
        }
    });

    pane.setEditable(false);

    scrollPane = new JScrollPane();
    scrollPane.setViewportView(this.pane);
    return scrollPane;
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:19,代码来源:Navigator.java

示例9: SwingTextComponent

import javax.swing.event.HyperlinkListener; //导入依赖的package包/类
public SwingTextComponent(final Document document)  {
  //super("text/html");
	this.document = document;
	
	configureEditor(this);
	addHyperlinkListener(new HyperlinkListener() {
         
         @Override
         public void hyperlinkUpdate(HyperlinkEvent event) {
           if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
             RequestHandler requestHandler = document.getRequestHandler();
             if (requestHandler != null) {
               try {
                 requestHandler.openLink(event.getURL().toURI());
               } catch (URISyntaxException e) {
                 e.printStackTrace();
               }
             }
           }
         }
       });
}
 
开发者ID:stefanhaustein,项目名称:nativehtml,代码行数:23,代码来源:SwingTextComponent.java

示例10: getJTextPane

import javax.swing.event.HyperlinkListener; //导入依赖的package包/类
/**
 * This method initializes jTextPane	
 * 	
 * @return javax.swing.JTextPane	
 */    
private JTextPane getJTextPane() {
	if (jTextPane == null) {
		jTextPane = new JTextPane();
		jTextPane.setContentType("text/html");
		jTextPane.setText(helpText);
		jTextPane.addHyperlinkListener(new HyperlinkListener() {
			public void hyperlinkUpdate(HyperlinkEvent e) {
				if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
					try{
						FileOpener opener = new MultiOSFileOpener();
						opener.open(e.getURL().toString());
					}catch (Exception ex) {
						logger.error("", ex);
					}
				}
			}
		});
		jTextPane.setEditable(false);			
	}
	return jTextPane;
}
 
开发者ID:terrier-org,项目名称:terrier-desktop,代码行数:27,代码来源:HelpDialog.java

示例11: createErrorPage

import javax.swing.event.HyperlinkListener; //导入依赖的package包/类
private void createErrorPage() {
  myErrorLabel.setOpaque(false);

  myErrorLabel.addHyperlinkListener(new HyperlinkListener() {
    @Override
    public void hyperlinkUpdate(HyperlinkEvent e) {
      initSceneBuilder(true);
    }
  });

  myErrorStack = new JTextArea(50, 20);
  myErrorStack.setEditable(false);

  myErrorPanel.add(myErrorLabel, BorderLayout.NORTH);
  myErrorPanel.add(ScrollPaneFactory.createScrollPane(myErrorStack), BorderLayout.CENTER);
  myPanel.add(myErrorPanel);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:SceneBuilderEditor.java

示例12: showErrorDialog

import javax.swing.event.HyperlinkListener; //导入依赖的package包/类
@Override
public void showErrorDialog(String name, String url) {
    JEditorPane ep = new JEditorPane("text/html",
            "<html>" +
                    owner + " was unable to download required library " + name +
                    "<br>Check your internet connection and try restarting or download it manually from" +
                    "<br><a href=\"" + url + "\">" + url + "</a> and put it in your mods folder" +
                    "</html>");

    ep.setEditable(false);
    ep.setOpaque(false);
    ep.addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent event) {
            try {
                if (event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
                    Desktop.getDesktop().browse(event.getURL().toURI());
            } catch (Exception e) {
            }
        }
    });

    JOptionPane.showMessageDialog(null, ep, "A download error has occured", JOptionPane.ERROR_MESSAGE);
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:25,代码来源:DepLoader.java

示例13: displayYellingData

import javax.swing.event.HyperlinkListener; //导入依赖的package包/类
@Override
public void displayYellingData() {
    StringBuilder builder = new StringBuilder();
    builder.append("<html>");
    for (String data : yellingData) {
        builder.append("<br>");
        builder.append(data);
    }
    builder.append("</html>");
    JEditorPane ep = new JEditorPane("text/html", builder.toString());
    ep.setAutoscrolls(true);
    ep.setEditable(false);
    ep.setOpaque(false);
    ep.addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent event) {
            try {
                if (event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
                    Desktop.getDesktop().browse(event.getURL().toURI());
                }
            } catch (Exception ignored) {
            }
        }
    });
    JOptionPane.showMessageDialog(null, ep, "DepLoader is Deprecated!", -1);
}
 
开发者ID:TheCBProject,项目名称:CodeChickenCore,代码行数:27,代码来源:DepLoader.java

示例14: showErrorDialog

import javax.swing.event.HyperlinkListener; //导入依赖的package包/类
@Override
public void showErrorDialog(String name, String url) {
    JEditorPane ep = new JEditorPane("text/html", "<html>" + owner + " was unable to download required library " + name + "<br>Check your internet connection and try restarting or download it manually from" + "<br><a href=\"" + url + "\">" + url + "</a> and put it in your mods folder" + "</html>");

    ep.setEditable(false);
    ep.setOpaque(false);
    ep.addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent event) {
            try {
                if (event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
                    Desktop.getDesktop().browse(event.getURL().toURI());
                }
            } catch (Exception e) {
            }
        }
    });

    JOptionPane.showMessageDialog(null, ep, "A download error has occured", JOptionPane.ERROR_MESSAGE);
}
 
开发者ID:TheCBProject,项目名称:CodeChickenCore,代码行数:21,代码来源:DepLoader.java

示例15: MessagePane

import javax.swing.event.HyperlinkListener; //导入依赖的package包/类
public MessagePane( final JDialog owner, final SessionMessage sessionMessage ) {
    super( "" );

    // insert our own hyperlink descriptions into the message, so translators can't mess them up
    Object[] args = { LINK_SHOW_STATISTICS_DETAILS, LINK_SHOW_SOFTWARE_AGREEMENT };
    String htmlFragment = MessageFormat.format( MESSAGE_PATTERN, args );
    setText( HTMLUtils.createStyledHTMLFromFragment( htmlFragment ) );

    addHyperlinkListener( new HyperlinkListener() {
        public void hyperlinkUpdate( HyperlinkEvent e ) {
            if ( e.getEventType() == HyperlinkEvent.EventType.ACTIVATED ) {
                if ( e.getDescription().equals( LINK_SHOW_STATISTICS_DETAILS ) ) {
                    showStatisticsDetails( owner, sessionMessage );
                }
                else if ( e.getDescription().equals( LINK_SHOW_SOFTWARE_AGREEMENT ) ) {
                    showSoftwareAgreement( owner );
                }
                else {
                    System.err.println( "SoftwareAgreementManager.MessagePane.hyperlinkUpdate: unsupported hyperlink, description=" + e.getDescription() );
                }
            }
        }
    } );
    setBackground( new JPanel().getBackground() );//see #1275
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:26,代码来源:SoftwareAgreementManager.java


注:本文中的javax.swing.event.HyperlinkListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。