public class Browser
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static com.Ostermiller.util.Browser.BrowserDialog |
dialog
The dialog that allows user configuration of the options for this class.
|
static java.lang.String[] |
exec
A list of commands to try in order to display the url.
|
protected static java.util.ResourceBundle |
labels
Locale specific strings displayed to the user.
|
Constructor and Description |
---|
Browser() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String[] |
defaultCommands()
Retrieve the default commands to open a browser for this system.
|
static boolean |
dialogConfiguration(java.awt.Frame owner)
Show a dialog that allows the user to configure the
command lines used for starting a browser on their system.
|
static boolean |
dialogConfiguration(java.awt.Frame owner,
java.util.Properties props)
Deprecated.
Use the com.Ostermiller.util.Browser resource bundle to set strings for the given locale.
|
static void |
displayURL(java.lang.String url)
Display a URL in the system browser.
|
static void |
displayURL(java.lang.String url,
java.lang.String namedWindow)
Display the URL in the named window.
|
static void |
displayURLinNew(java.lang.String url)
Display the URL in a new window.
|
static void |
displayURLs(java.lang.String[] urls)
Display the URLs, each in their own window, in the system browser.
|
static void |
displayURLs(java.lang.String[] urls,
java.lang.String namedWindow)
Display the URLs the first in the given named window.
|
static void |
displayURLs(java.lang.String[] urls,
java.lang.String[] namedWindows)
Display the URLs in the named windows.
|
static void |
displayURLsinNew(java.lang.String[] urls)
Display the URLs, each in their own window, in the system browser and the first in
the named window.
|
static javax.swing.JPanel |
getDialogPanel(java.awt.Window parent)
If you wish to add to your own dialog box rather than have a separate
one just for the browser, use this method to get a JPanel that can
be added to your own dialog.
|
static void |
init()
Determine appropriate commands to start a browser on the current
operating system.
|
static void |
initPanel()
If you are using the getDialogPanel() method to create your own dialog, this
method should be called every time before you display the dialog.
|
static void |
load(java.util.Properties props)
Load the options for this class from the given properties file.
|
static void |
main(java.lang.String[] args)
Open the url(s) specified on the command line in your browser.
|
static void |
save(java.util.Properties props)
Save the options used to the given properties file.
|
static void |
setLocale(java.util.Locale locale)
Set the locale used for getting localized
strings.
|
static void |
userOKedPanelChanges()
If you are using the getDialogPanel() method to create your own dialog, this
method should be called after you display the dialog if the user pressed ok.
|
protected static com.Ostermiller.util.Browser.BrowserDialog dialog
protected static java.util.ResourceBundle labels
public static java.lang.String[] exec
rundll32 url.dll,FileProtocolHandler {0}
netscape {0}
public static void setLocale(java.util.Locale locale)
locale
- Locale used to for i18n.public static void init()
rundll32 url.dll,FileProtocolHandler {0}
On other operating systems, the "which" command is used to
test if Mozilla, netscape, and lynx(xterm) are available (in that
order).public static java.lang.String[] defaultCommands()
public static void save(java.util.Properties props)
props
- properties file to which configuration is saved.public static void load(java.util.Properties props)
props
- properties file from which configuration is loaded.public static void displayURL(java.lang.String url) throws java.io.IOException
url
- the url to displayjava.io.IOException
- if the url is not valid or the browser fails to starpublic static void displayURLs(java.lang.String[] urls) throws java.io.IOException
urls
- the list of urls to displayjava.io.IOException
- if the url is not valid or the browser fails to starpublic static void displayURLinNew(java.lang.String url) throws java.io.IOException
url
- the url to display in a new window.java.io.IOException
- if the url is not valid or the browser fails to starpublic static void displayURLsinNew(java.lang.String[] urls) throws java.io.IOException
urls
- the list of urls to displayjava.io.IOException
- if the url is not valid or the browser fails to starpublic static void displayURL(java.lang.String url, java.lang.String namedWindow) throws java.io.IOException
url
- the url to displaynamedWindow
- the name of the desired window.java.io.IOException
- if the url is not valid or the browser fails to starpublic static void displayURLs(java.lang.String[] urls, java.lang.String[] namedWindows) throws java.io.IOException
urls
- the list of urls to displaynamedWindows
- the list of names for the windows.java.io.IOException
- if the url is not valid or the browser fails to starpublic static void displayURLs(java.lang.String[] urls, java.lang.String namedWindow) throws java.io.IOException
urls
- the list of urls to displaynamedWindow
- the name of the first window to use.java.io.IOException
- if the url is not valid or the browser fails to starpublic static void main(java.lang.String[] args)
args
- Command line arguments (URLs)public static boolean dialogConfiguration(java.awt.Frame owner)
owner
- The frame that owns the dialog.@Deprecated public static boolean dialogConfiguration(java.awt.Frame owner, java.util.Properties props)
Properties that are used:
com.Ostermiller.util.BrowserDialog.title
com.Ostermiller.util.BrowserDialog.description
com.Ostermiller.util.BrowserDialog.label
com.Ostermiller.util.BrowserDialog.defaults
com.Ostermiller.util.BrowserDialog.browse
com.Ostermiller.util.BrowserDialog.ok
com.Ostermiller.util.BrowserDialog.cancel
owner
- The frame that owns this dialog.props
- contains the strings used in the dialog.public static javax.swing.JPanel getDialogPanel(java.awt.Window parent)
parent
- window into which panel with eventually be placed.public static void initPanel()
public static void userOKedPanelChanges()
Copyright (c) 2001-2020 by Stephen Ostermiller