本文整理汇总了Java中edu.stanford.ejalbert.BrowserLauncher类的典型用法代码示例。如果您正苦于以下问题:Java BrowserLauncher类的具体用法?Java BrowserLauncher怎么用?Java BrowserLauncher使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BrowserLauncher类属于edu.stanford.ejalbert包,在下文中一共展示了BrowserLauncher类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: menuAboutDiscussionGroupActionPerformed
import edu.stanford.ejalbert.BrowserLauncher; //导入依赖的package包/类
private void menuAboutDiscussionGroupActionPerformed(
java.awt.event.ActionEvent e) {
try {
if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
URI groupURI = new URI(ModelTest.DISCUSSION_GROUP);
desktop.browse(groupURI);
} else {
BrowserLauncher launcher = new BrowserLauncher();
launcher.openURLinBrowser(ModelTest.DISCUSSION_GROUP);
}
} catch (Exception f) {
JOptionPane.showMessageDialog(new JFrame(), f.getMessage(),
"Error loading webpage", JOptionPane.ERROR_MESSAGE);
}
}
示例2: linkActivated
import edu.stanford.ejalbert.BrowserLauncher; //导入依赖的package包/类
/**
* Called if someone has activated a hyperlink.
*
* @param u URL of the link
*/
protected void linkActivated(URL u)
{
// external links are loaded by the BrowserLauncher
if (u.getProtocol().equals("http")
|| u.getProtocol().equals("https"))
{
try
{
BrowserLauncher.openURL(u.toString());
}
catch (IOException e)
{
Common.setMessage(Resource.getString("msg.browser.launcher.error") + " " + e);
}
}
else
{
// all local links are loaded into the JEditorPane
Cursor c = html.getCursor();
Cursor waitCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
html.setCursor(waitCursor);
SwingUtilities.invokeLater(new PageLoader(u, c));
}
}
示例3: openBrowser
import edu.stanford.ejalbert.BrowserLauncher; //导入依赖的package包/类
public void openBrowser() {
String url = "http://127.0.0.1:"
+ httpServer.getPort() + "/";
try {
Desktop.getDesktop().browse(new URI(url));
} catch (Exception e1) {
try {
new BrowserLauncher().openURLinBrowser(url);
} catch (Exception e2) {
e1.printStackTrace();
e2.printStackTrace();
JOptionPane.showMessageDialog(null, e1.getLocalizedMessage());
}
}
}
示例4: OSMCreditPanel
import edu.stanford.ejalbert.BrowserLauncher; //导入依赖的package包/类
/**
* Konstruktor
*/
public OSMCreditPanel() {
super(new FlowLayout(FlowLayout.CENTER));
JLabel lab = new JLabel("Map data \u00a9 ");
lab.setFont(font);
lab.setForeground(new Color(0x505050));
add(lab);
lab = new JLabel("OpenStreetMap");
lab.setCursor(new Cursor(Cursor.HAND_CURSOR));
Map<TextAttribute, Integer> fontAttr = new HashMap<>();
fontAttr.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
lab.setFont(font.deriveFont(fontAttr));
lab.setForeground(new Color(0x330066));
add(lab);
lab.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
try {
new BrowserLauncher().openURLinBrowser("http://www.openstreetmap.org/copyright");
} catch (BrowserLaunchingInitializingException | UnsupportedOperatingSystemException ex) {
System.err.println(ex);
}
}
});
lab = new JLabel(" contributors");
lab.setFont(font);
lab.setForeground(new Color(0x505050));
add(lab);
setBackground(new Color(210, 210, 210, 170));
setOpaque(true);
setPreferredSize(new Dimension(270, 24));
}
示例5: menuHelpOpenActionPerformed
import edu.stanford.ejalbert.BrowserLauncher; //导入依赖的package包/类
private void menuHelpOpenActionPerformed(java.awt.event.ActionEvent e) {
try {
if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
URI wikiURI = new URI(ModelTest.WIKI);
desktop.browse(wikiURI);
} else {
BrowserLauncher launcher = new BrowserLauncher();
launcher.openURLinBrowser(ModelTest.WIKI);
}
} catch (Exception f) {
JOptionPane.showMessageDialog(new JFrame(), f.getMessage(),
"Error loading webpage", JOptionPane.ERROR_MESSAGE);
}
}
示例6: menuAboutWWWActionPerformed
import edu.stanford.ejalbert.BrowserLauncher; //导入依赖的package包/类
private void menuAboutWWWActionPerformed(java.awt.event.ActionEvent e) {
try {
if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
URI jModelTestURI = new URI(ModelTest.URL);
desktop.browse(jModelTestURI);
} else {
BrowserLauncher launcher = new BrowserLauncher();
launcher.openURLinBrowser(ModelTest.URL);
}
} catch (Exception f) {
JOptionPane.showMessageDialog(new JFrame(), f.getMessage(),
"Error loading webpage", JOptionPane.ERROR_MESSAGE);
}
}
示例7: showHtmlWindow
import edu.stanford.ejalbert.BrowserLauncher; //导入依赖的package包/类
private void showHtmlWindow(String title,String text) {
JPanel panel = new JPanel(new BorderLayout());
JEditorPane pane = new JEditorPane("text/html",text) {
public boolean isFocusTraversable() {
return false;
}
};
pane.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
try {
URL url = e.getURL();
BrowserLauncher.openURL(url.toString());
}
catch(IOException ex) {
// do nothing
}
}
}
});
pane.setEditable(false);
pane.setOpaque(false);
panel.add(pane,BorderLayout.CENTER);
Box box = Box.createHorizontalBox();
box.add(Box.createHorizontalGlue());
JButton creditsButton = new JButton("RealmSpeak Credits...");
creditsButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
showCredits();
}
});
box.add(creditsButton);
panel.add(box,BorderLayout.SOUTH);
FrameManager.showDefaultManagedFrame(this,panel,title,IconFactory.findIcon("images/logo/realmbox.jpg"),true);
}