本文整理汇总了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);
}
}
}
}
};
}
示例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);
}
}
}
}
});
}
示例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;
}
示例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());
}
}
});
}
示例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());
}
}
}
});
}
示例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());
}
}
}
});
}
示例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");
}
});
}
示例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;
}
示例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();
}
}
}
}
});
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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
}