本文整理了Java中javax.swing.JTextPane.addHyperlinkListener()
方法的一些代码示例,展示了JTextPane.addHyperlinkListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextPane.addHyperlinkListener()
方法的具体详情如下:
包路径:javax.swing.JTextPane
类名称:JTextPane
方法名:addHyperlinkListener
暂无
代码示例来源:origin: chewiebug/GCViewer
private void initComponents(String fileName) {
super.initComponents();
JTextPane textPane = new JTextPane();
textPane.setEditable(false);
textPane.setContentType("text/html");
textPane.addHyperlinkListener(new HyperlinkAdapter(this));
try {
textPane.setText(readFile(fileName));
textPane.setCaretPosition(0);
}
catch (IOException e) {
e.printStackTrace();
}
JScrollPane scrollPane = new JScrollPane(
textPane,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
getContentPane().add("Center", scrollPane);
pack();
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@NotNull
public static JTextPane createDescriptionPane() {
JTextPane result = new JTextPane();
result.addHyperlinkListener(new BrowserHyperlinkListener());
result.setContentType("text/html");
Font descriptionFont = UIUtil.getLabelFont(UIUtil.FontSize.SMALL);
HTMLEditorKit editorKit = UIUtil.getHTMLEditorKit();
editorKit.getStyleSheet().addRule("body, p {" +
"color:#" + ColorUtil.toHex(UIUtil.getLabelFontColor(UIUtil.FontColor.BRIGHTER)) + ";" +
"font-family:" + descriptionFont.getFamily() + ";" +
"font-size:" + descriptionFont.getSize() + "pt;}");
result.setHighlighter(null);
result.setEditorKit(editorKit);
return result;
}
}
代码示例来源:origin: org.languagetool/languagetool-gui-commons
static void addHyperlinkListener(JTextPane pane) {
pane.addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
Tools.openURL(e.getURL());
}
}
});
}
代码示例来源:origin: xyz.cofe/docking-frames-core
private void initHyperlinking( JTextPane pane ){
pane.addHyperlinkListener( new HyperlinkListener(){
public void hyperlinkUpdate( HyperlinkEvent e ){
if( e.getEventType() == HyperlinkEvent.EventType.ACTIVATED ){
try{
Class<?> desktopClass = Class.forName( "java.awt.Desktop" );
Object desktop = desktopClass.getMethod( "getDesktop" ).invoke( null );
Method browse = desktopClass.getMethod( "browse", URI.class );
browse.invoke( desktop, e.getURL().toURI() );
}
catch( Exception ex ){
ex.printStackTrace();
JOptionPane.showMessageDialog( dialog, "I was unable to open your browser :-(", "Cannot open link", JOptionPane.ERROR_MESSAGE );
}
}
}
});
}
代码示例来源:origin: org.opentcs.thirdparty.dockingframes/docking-frames-core
private void initHyperlinking( JTextPane pane ){
pane.addHyperlinkListener( new HyperlinkListener(){
public void hyperlinkUpdate( HyperlinkEvent e ){
if( e.getEventType() == HyperlinkEvent.EventType.ACTIVATED ){
try{
Class<?> desktopClass = Class.forName( "java.awt.Desktop" );
Object desktop = desktopClass.getMethod( "getDesktop" ).invoke( null );
Method browse = desktopClass.getMethod( "browse", URI.class );
browse.invoke( desktop, e.getURL().toURI() );
}
catch( Exception ex ){
ex.printStackTrace();
JOptionPane.showMessageDialog( dialog, "I was unable to open your browser :-(", "Cannot open link", JOptionPane.ERROR_MESSAGE );
}
}
}
});
}
代码示例来源:origin: MegaMek/mekhq
public DailyReportLogPanel(ReportHyperlinkListener listener) {
txtLog = new JTextPane() {
/**
*
*/
private static final long serialVersionUID = 9000659006965230883L;
public boolean getScrollableTracksViewportWidth() {
return true;
}
};
txtLog.addHyperlinkListener(listener);
initComponents();
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-kenai-ui
srcFeedPane.addHyperlinkListener(new HyperlinkListener() {
代码示例来源:origin: edu.illinois.lis/indri
/** Create the frame that shows the help file and render the html.
*/
private void makeHelp() {
java.net.URL helpURL = IndexUI.class.getResource(helpFile);
JTextPane help = new JTextPane();
//Create and set up the window.
helpFrame = new JFrame("Indri Index Builder Help");
help.setPreferredSize(new Dimension(650, 400));
help.setEditable(false);
help.addHyperlinkListener(new DocLinkListener(indriIcon.getImage()));
JScrollPane scroller = new JScrollPane(help);
try {
help.setPage(helpURL);
} catch (IOException ex) {
help.setText("Help file unavailable.");
}
helpFrame.getContentPane().add(scroller, BorderLayout.CENTER);
helpFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
helpFrame.setIconImage(indriIcon.getImage());
helpFrame.pack();
}
代码示例来源:origin: edu.illinois.lis/indri
/** Create the frame that shows the help file and render the html.
Saves time when the user opens the help.
*/
private void makeHelp() {
java.net.URL helpURL = RetUI.class.getResource(helpFile);
Image image = createImageIcon(iconFile).getImage();
JTextPane help = new JTextPane();
//Create and set up the window.
helpFrame = new JFrame("Indri Retrieval UI Help");
help.setPreferredSize(new Dimension(650, 400));
help.setEditable(false);
help.addHyperlinkListener(new DocLinkListener(image));
JScrollPane scroller = new JScrollPane(help);
try {
help.setPage(helpURL);
} catch (IOException ex) {
help.setText("Help file unavailable.");
}
helpFrame.getContentPane().add(scroller, BorderLayout.CENTER);
helpFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
helpFrame.setIconImage(image);
helpFrame.pack();
}
代码示例来源:origin: stackoverflow.com
final JTextPane pane = new JTextPane();
pane.setEditable(false);
pane.setContentType("text/html");
pane.setPage("http://swingx.java.net");
ToolTipManager.sharedInstance().registerComponent(pane);
HyperlinkListener l = new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (HyperlinkEvent.EventType.ACTIVATED == e.getEventType()) {
try {
pane.setPage(e.getURL());
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
};
pane.addHyperlinkListener(l);
代码示例来源:origin: GoogleCloudPlatform/google-cloud-intellij
/**
* Initializes some UI components in this panel that require special set-up.
*
* <p>This is automatically called by the IDEA SDK and should not be directly invoked.
*/
private void createUIComponents() {
descriptionTextPane = new JTextPane();
descriptionTextPane.setOpaque(false);
linksTextPane = new JTextPane();
linksTextPane.setOpaque(false);
linksTextPane.addHyperlinkListener(new BrowserOpeningHyperLinkListener());
apiManagementPanel = new JPanel();
apiManagementPanel.setBorder(
IdeBorderFactory.createTitledBorder(
GoogleCloudApisMessageBundle.message("cloud.apis.management.section.title")));
managementWarningTextPane = new JTextPane();
managementWarningTextPane.setOpaque(false);
warningLabel = new JLabel();
warningLabel.setIcon(General.Information);
enableApiCheckbox = new JCheckBox();
enableApiCheckbox.addActionListener(
event ->
currentCloudApiManagementSpec.setShouldEnable(
((JCheckBox) event.getSource()).isSelected()));
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mercurial
@Override
protected void setupPane(JTextPane pane, final File[] files, final File projectDir, final String url, final String revision) {
String text = NbBundle.getMessage(
KenaiNotificationListener.class,
"MSG_NotificationBubble_Description",
getFileNames(files),
HgKenaiAccessor.getInstance().getRevisionUrl(url, revision)); //NOI18N
pane.setText(text);
pane.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
URL url = e.getURL();
assert url != null;
HtmlBrowser.URLDisplayer displayer = HtmlBrowser.URLDisplayer.getDefault ();
assert displayer != null : "HtmlBrowser.URLDisplayer found."; //NOI18N
if (displayer != null) {
displayer.showURL (url);
} else {
Mercurial.LOG.info("No URLDisplayer found."); //NOI18N
}
}
}
});
}
代码示例来源:origin: GoogleCloudPlatform/google-cloud-intellij
public CloudSdkPanel() {
warningMessage.setVisible(false);
warningMessage.setBackground(cloudSdkPanel.getBackground());
warningMessage.addHyperlinkListener(new BrowserOpeningHyperLinkListener());
warningIcon.setVisible(false);
warningIcon.setIcon(RunConfigurations.ConfigurationWarning);
checkManagedSdkFeatureStatus();
initEvents();
}
代码示例来源:origin: cytoscape.coreplugins/biopax
/**
* Constructor.
*/
public BioPaxDetailsPanel() {
JLabel label = new JLabel();
textPane = new JTextPane();
// Set Editor Kit that is capable of handling long words
MyEditorKit kit = new MyEditorKit();
textPane.setEditorKit(kit);
modifyStyleSheetForSingleDocument(textPane);
textPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
textPane.setBorder(new EmptyBorder (5,5,5,5));
textPane.setContentType("text/html");
textPane.setEditable(false);
textPane.addHyperlinkListener(new LaunchExternalBrowser());
resetText();
scrollPane = new JScrollPane(textPane);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scrollPane.setBorder(new EmptyBorder(0, 0, 0, 0));
this.setLayout(new BorderLayout());
this.add(scrollPane, BorderLayout.CENTER);
this.setPreferredSize(new Dimension(300, 300));
this.setMaximumSize(new Dimension(300, 300));
// get a ref to node attributes
nodeAttributes = Cytoscape.getNodeAttributes();
}
代码示例来源:origin: nroduit/Weasis
public SRView(Series<?> series) {
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
htmlPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
htmlPanel.setEditorKit(JMVUtils.buildHTMLEditorKit(htmlPanel));
htmlPanel.setContentType("text/html"); //$NON-NLS-1$
htmlPanel.setEditable(false);
htmlPanel.addHyperlinkListener(e -> {
JTextPane pane = (JTextPane) e.getSource();
if (e.getEventType() == HyperlinkEvent.EventType.ENTERED) {
pane.setToolTipText(e.getDescription());
} else if (e.getEventType() == HyperlinkEvent.EventType.EXITED) {
pane.setToolTipText(null);
} else if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
String desc = e.getDescription();
URL url = e.getURL();
if (url == null && desc != null && desc.startsWith("#")) { //$NON-NLS-1$
htmlPanel.scrollToReference(desc.substring(1));
} else {
openRelatedSeries(e.getURL().getHost());
}
}
});
setPreferredSize(new Dimension(1024, 1024));
setSeries(series);
}
代码示例来源:origin: org.codehaus.izpack/izpack-panel
label.addHyperlinkListener(new HyperlinkHandler());
代码示例来源:origin: GoogleCloudPlatform/google-cloud-intellij
@Override
protected void init() {
super.init();
setTitle(AppEngineMessageBundle.message("appengine.application.region.select"));
refreshLocationsSelector();
statusPanel.setVisible(false);
errorIcon.setVisible(false);
regionComboBox.addItemListener(
(event) -> {
if (event.getStateChange() == ItemEvent.SELECTED) {
updateLocationDetailMessage();
}
});
regionDetailPane.addHyperlinkListener(new BrowserOpeningHyperLinkListener());
instructionsTextPane.addHyperlinkListener(new BrowserOpeningHyperLinkListener());
instructionsTextPane.setText(
HTML_OPEN_TAG
+ AppEngineMessageBundle.message("appengine.application.create.instructions")
+ "<p>"
+ AppEngineMessageBundle.message(
"appengine.application.create.documentation",
"<a href=\"" + LOCATIONS_DOCUMENTATION_URL + "\">",
"</a>")
+ "</p>"
+ HTML_CLOSE_TAG);
FontUtils.convertStyledDocumentFontToDefault(instructionsTextPane.getStyledDocument());
}
代码示例来源:origin: GoogleCloudPlatform/google-cloud-intellij
appEngineMoreInfoLabel.addHyperlinkListener(
new BrowserOpeningHyperLinkListener() {
@Override
代码示例来源:origin: net.sf.ingenias/editor
public void initialiseActionHandlers() {
try {
ids.addStateChangelistener(new IDEChangesHandler(ids,resources));
ManageExtensions me=new ManageExtensions(ids,resources,this);
ModuleLoader.cleanExtensionFolder();
ModuleLoader ml=null;
try {
ml = new ModuleLoader(new URL("file:ext/"));
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
diagramLocator = new HyperlinkAction(ids,resources);
searchDiagramPanel.addHyperlinkListener(diagramLocator);
logs.addHyperlinkListener(diagramLocator);
this.abackup=new AutomaticBackupAction(ids,resources,5);
me=new ManageExtensions(ids,resources,this);
update = new UpdateToolsAndCG(me,ml,ids);
update.readLibs("ext");
update.start();
}catch (Throwable t){
t.printStackTrace();
}
}
代码示例来源:origin: cytoscape.coreplugins/cpath2
textPane.setContentType("text/html");
textPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
textPane.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) {
if (hyperlinkEvent.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
内容来源于网络,如有侵权,请联系作者删除!