|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectkiwi.ui.WebBrowser
A class that represents a web browser and provides URL opening capability. This class allows a Java program to open a URL in a web browser. It currently works on Windows and UNIX systems.
On Windows, the URL is opened in the default browser by invoking the command:
rundll32 url.dll,FileProtocolHandler urlThis calling convention works on most variants of Windows, from Windows 98 to Windows 2000. It has not been tested on Windows XP.
On UNIX, this class can launch (or send a remote command to) any Netscape-compatible browser which supports the ``-remote'' switch; this includes Netscape itself, Mozilla, and possibly other browsers. An attempt is first made to open the URL in a running browser, via a command like:
netscape -remote openURL(url)and if that fails, an attempt is then made to launch the browser, via a command like:
netscape urlIn the case of an error, an exception is thrown.
On MacOS, the equivalent result can be achieved by using the method:
com.apple.mrj.MRJUtils.openURL(String url) throws IOExceptionSince this call relies on an OS-specific class library, MacOS support has not been added to this class, as doing so would break the compilation on non-MacOS systems.
Field Summary | |
private java.lang.String |
browserPath
|
private static java.lang.String[] |
unixBrowsers
|
private static java.lang.String[] |
unixCommands
|
private boolean |
windows
|
private static java.lang.String[] |
windowsBrowsers
|
private static java.lang.String[] |
windowsCommands
|
Constructor Summary | |
WebBrowser()
Construct a new WebBrowser , with no browser path specified. |
Method Summary | |
private boolean |
isWindows()
|
void |
openURL(java.lang.String url)
Open the specified URL in the web browser. |
private void |
openURL(java.lang.String url,
java.lang.String browser,
java.lang.String[] commandList)
|
void |
openURL(java.net.URL url)
Open the specified URL in the web browser. |
void |
setBrowserPath(java.lang.String path)
Specify the path to a Netscape-compatible browser (such as Netscape, Mozilla, or any other browser that supports the ``-remote'' switch). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private boolean windows
private java.lang.String browserPath
private static final java.lang.String[] unixCommands
private static final java.lang.String[] unixBrowsers
private static final java.lang.String[] windowsCommands
private static final java.lang.String[] windowsBrowsers
Constructor Detail |
public WebBrowser()
WebBrowser
, with no browser path specified.
An attempt will be made to use mozilla or netscape, in that order. It
will be assumed that a browser binary can be found in the command
search path.
Method Detail |
public void setBrowserPath(java.lang.String path)
This method has no effect on Windows systems.
path
- The path to the browser.public void openURL(java.net.URL url) throws java.io.IOException
url
- The URL to open.
java.io.IOException
- If the browser could not be launched.public void openURL(java.lang.String url) throws java.io.IOException
url
- The URL to open.
java.io.IOException
- If the browser could not be launched.private void openURL(java.lang.String url, java.lang.String browser, java.lang.String[] commandList) throws java.io.IOException
java.io.IOException
private boolean isWindows()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |