org.browsecode.helpers.html
Class OpenInBrowser
java.lang.Object
org.browsecode.helpers.html.OpenInBrowser
public class OpenInBrowser
- extends java.lang.Object
Open a URL in a browser.
Combines a number of different tricks to try to load the URL into a browser.
Method Summary |
static PopupMenuShower |
addHTMLHelpRightClickMenu(javax.swing.JComponent component,
java.lang.String menuItemName,
java.lang.String htmlWebsite)
|
protected static boolean |
displayURLViaCommandLine(java.net.URL url)
Display a file in the system browser. |
protected static boolean |
displayURLViaJavaWebBrowser(java.net.URL url)
Use this only as a last ditch effort, because the rendering engine is horrible -- and there's no forward/back buttons, etc. |
static boolean |
openInBrowser(java.net.URL url)
This may be slow -- if it succeeds, it may not return until the web browser has exited, depending upon which command is called (it would be nice to fix that). |
static void |
openInBrowserInThread(java.net.URL url)
The regular openInBrowser method may be slow -- may not return until the web browser has exited. |
protected static boolean |
runExitsGood(java.lang.String command)
|
protected static boolean |
showDocumentViaJNLP(java.net.URL url)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
serviceManagerClass
protected static java.lang.Class serviceManagerClass
basicServiceObject
protected static java.lang.Object basicServiceObject
basicServiceClass
protected static java.lang.Class basicServiceClass
debuggingOutput
protected static java.lang.String debuggingOutput
OpenInBrowser
public OpenInBrowser()
showDocumentViaJNLP
protected static boolean showDocumentViaJNLP(java.net.URL url)
runExitsGood
protected static boolean runExitsGood(java.lang.String command)
displayURLViaCommandLine
protected static boolean displayURLViaCommandLine(java.net.URL url)
- Display a file in the system browser. If you want to display a
file, you must include the absolute path name.
Based off code from:
http://www.javaworld.com/javaworld/javatips/jw-javatip66.html
- Parameters:
url
- the file's url
displayURLViaJavaWebBrowser
protected static boolean displayURLViaJavaWebBrowser(java.net.URL url)
- Use this only as a last ditch effort, because the rendering engine is horrible -- and there's no forward/back buttons, etc.
- Parameters:
url
-
- Returns:
openInBrowser
public static boolean openInBrowser(java.net.URL url)
- This may be slow -- if it succeeds, it may not return until the web browser has exited, depending upon which command is called (it would be nice to fix that). We recommend running this in a thread separate from the GUI, i.e.
public void actionPerformed(ActionEvent e) {
Thread thread = new Thread(new Runnable(){
public void run() {
try {
OpenInBrowser.openInBrowser(new URL("http://jspsurveylib.sourceforge.net"));
} catch (MalformedURLException urle) {
Maintenance.sendBug(urle);
}
}});
thread.start();
}
- Parameters:
url
-
- Returns:
openInBrowserInThread
public static void openInBrowserInThread(java.net.URL url)
- The regular openInBrowser method may be slow -- may not return until the web browser has exited. Thus, you may want to call this instead.
The downside is you don't know if it succeeds.
- Parameters:
url
-
addHTMLHelpRightClickMenu
public static PopupMenuShower addHTMLHelpRightClickMenu(javax.swing.JComponent component,
java.lang.String menuItemName,
java.lang.String htmlWebsite)
- Parameters:
component
- menuItemName
- htmlWebsite
-
- Returns:
- the PopupMenuShower, in case you ever want to remove it later.