本文整理汇总了Java中javax.swing.event.HyperlinkEvent类的典型用法代码示例。如果您正苦于以下问题:Java HyperlinkEvent类的具体用法?Java HyperlinkEvent怎么用?Java HyperlinkEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HyperlinkEvent类属于javax.swing.event包,在下文中一共展示了HyperlinkEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createHyperlinkListener
import javax.swing.event.HyperlinkEvent; //导入依赖的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.HyperlinkEvent; //导入依赖的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: hyperlinkUpdate
import javax.swing.event.HyperlinkEvent; //导入依赖的package包/类
public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) {
url = hyperlinkEvent.getURL();
HyperlinkEvent.EventType type = hyperlinkEvent.getEventType();
if (type == HyperlinkEvent.EventType.ENTERED) {
isInsideHyperlink = true;
pane.setToolTipText(getURLExternalForm()); // #176141
}
else if (type == HyperlinkEvent.EventType.ACTIVATED) {
isInsideHyperlink = false;
pane.setToolTipText(null);
}
else if (type == HyperlinkEvent.EventType.EXITED) {
isInsideHyperlink = false;
pane.setToolTipText(null);
}
else {
Installer.log.log(Level.SEVERE, "Unknown hyperlinkEvent: " +
hyperlinkEvent);
}
}
示例4: hyperlinkUpdate
import javax.swing.event.HyperlinkEvent; //导入依赖的package包/类
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e != null && HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
final String desc = e.getDescription();
if (desc != null) {
RP.post(new Runnable() {
public @Override void run() {
final ElementJavadoc cd;
synchronized (DocumentationScrollPane.this) {
cd = currentDocumentation;
}
if (cd != null) {
final ElementJavadoc doc = cd.resolveLink(desc);
if (doc != null) {
EventQueue.invokeLater(new Runnable() {
public @Override void run() {
setData(doc, false);
}
});
}
}
}
});
}
}
}
示例5: hyperlinkUpdate
import javax.swing.event.HyperlinkEvent; //导入依赖的package包/类
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e != null && HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
final String desc = e.getDescription();
if (desc != null) {
RP.post(new Runnable() {
public @Override void run() {
CompletionDocumentation cd = currentDocumentation;
if (cd != null) {
final CompletionDocumentation doc = cd.resolveLink(desc);
if (doc != null) {
EventQueue.invokeLater(new Runnable() {
public @Override void run() {
setData(doc);
}
});
}
}
}
});
}
}
}
示例6: createInfoPanel
import javax.swing.event.HyperlinkEvent; //导入依赖的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;
}
示例7: FixedWidthEditorPane
import javax.swing.event.HyperlinkEvent; //导入依赖的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());
}
}
});
}
示例8: init
import javax.swing.event.HyperlinkEvent; //导入依赖的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());
}
}
}
});
}
示例9: MessageWithLink
import javax.swing.event.HyperlinkEvent; //导入依赖的package包/类
public MessageWithLink(String htmlBody) {
super("text/html", "<html><body style=\"" + getStyle() + "\">" + htmlBody + "</body></html>");
addHyperlinkListener(e -> {
if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
// Process the click event on the link (for example with java.awt.Desktop.getDesktop().browse())
URI uri = URI.create(String.valueOf(e.getURL()));
try {
Desktop.getDesktop().browse(uri);
} catch (IOException e1) {
e1.printStackTrace();
}
}
});
setEditable(false);
setBorder(null);
}
示例10: init
import javax.swing.event.HyperlinkEvent; //导入依赖的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());
}
}
}
});
}
示例11: JTextPaneTableCellRenderer
import javax.swing.event.HyperlinkEvent; //导入依赖的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");
}
});
}
示例12: actionPerformed
import javax.swing.event.HyperlinkEvent; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
long maxHeap = Runtime.getRuntime().maxMemory();
int cpus = Runtime.getRuntime().availableProcessors();
JTextPane aboutField = new JTextPane();
aboutField.setContentType("text/html");
aboutField.setText("Image to ZX Spec is a simple to use program which applies a Sinclair ZX Spectrum<br>" +
"effect to images, creates Spectrum playable slideshows from images or \"video\"<br>" +
"from compatible video files.<br><br>"+
"This software is copyright Silent Software (Benjamin Brown), uses Caprica Software<br>"+
"Limited's VLCJ and Art Clarke's Humble Video as well as other open source libraries.<br>"+
"See the included licences.txt for full details.<br><br>" +
"Processors: "+cpus+"<br>"+
"Total Java Memory: "+maxHeap/1024/1024+"MB<br><br>"+
"Visit Silent Software at <a href='"+HOME_PAGE+"'>"+HOME_PAGE+"</a><br><br>"+
"If you like this program and find it useful don't forget to <a href='"+COFFEE_LINK+"'>buy the developer a coffee!</a>");
aboutField.putClientProperty(JTextPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
aboutField.setEditable(false);
aboutField.setOpaque(false);
aboutField.addHyperlinkListener(e1 -> {
if (HyperlinkEvent.EventType.ACTIVATED == e1.getEventType()) {
openLink(e1.getURL());
}
});
JOptionPane.showMessageDialog(null, aboutField, "About Image to ZX Spec", JOptionPane.INFORMATION_MESSAGE, ImageToZxSpec.IMAGE_ICON);
}
示例13: showPopupIfNecessary
import javax.swing.event.HyperlinkEvent; //导入依赖的package包/类
void showPopupIfNecessary() {
log.debug("Application starts: {}", optionsObject.getStarts());
if (optionsObject.getStarts() == STARTS_BEFORE_COFFEE) {
JTextPane aboutField = new JTextPane();
aboutField.setContentType("text/html");
aboutField.setText("<h2>You seem to be enjoying Image to ZX Spec!</h2>" +
"Did you know Image to ZX Spec has been in development for the last 7 years?<br>"+
"That's a lot of coffee, so please consider a contribution of any amount to the<br>"+
"developer's coffee buying budget!<br>"+
"<h3><a href='"+COFFEE_LINK+"'>Buy the developer a coffee</a></h3>"+
"This popup will never be shown again, but if you want to buy a coffee later you can<br>"+
"always find the link in the About dialog.<br><br>"+
"<b>Thank you for your support.</b>");
aboutField.putClientProperty(JTextPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
aboutField.setEditable(false);
aboutField.setOpaque(false);
aboutField.addHyperlinkListener(e -> {
if (HyperlinkEvent.EventType.ACTIVATED == e.getEventType()) {
openLink(e.getURL());
}
});
JOptionPane.showMessageDialog(null, aboutField, "Information", JOptionPane.INFORMATION_MESSAGE, ImageToZxSpec.IMAGE_ICON);
}
optionsObject.setStarts((optionsObject.getStarts()+1));
PreferencesService.save();
}
示例14: createComponent
import javax.swing.event.HyperlinkEvent; //导入依赖的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;
}
示例15: hyperlinkUpdate
import javax.swing.event.HyperlinkEvent; //导入依赖的package包/类
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
HyperlinkEvent.EventType type = e.getEventType();
if (type == HyperlinkEvent.EventType.ACTIVATED) {
String[] path = e.getURL().getPath().split("/");
if (null != path[1]) {
switch (path[1]) {
case FreeColObject.ID_ATTRIBUTE_TAG:
select(path[2]);
break;
case "action":
getFreeColClient().getActionManager()
.getFreeColAction(path[2]).actionPerformed(null);
break;
default:
break;
}
}
}
}