1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
// CLASSIFICATION: UNCLASSIFIED
package mspccs_spreadsheet_tester.utility;
/*
* StartBrowser.java
*
* Created on June 14, 2001, 9:02 AM
*/
/**
*
* @author amyc
* @version
*/
public class StartBrowser extends Object {
/** Creates new StartBrowser */
public StartBrowser() {
}
// The url must start with either "http://" or
//"file://".
public static void displayURL(java.awt.Component parent, String url)
{
boolean windows = isWindowsPlatform();
String browserCommand = null;
try
{
if (windows)
{
// browserCommand = 'rundll32 url.dll,FileProtocolHandler http://...'
browserCommand = WIN_PATH + " " + WIN_FLAG + " " + url;
Process process = Runtime.getRuntime().exec(browserCommand);
}
else
{
// browserCommand = 'netscape http://www.javaworld.com'
browserCommand = UNIX_PATH + " " + url;
Process process = Runtime.getRuntime().exec(browserCommand);
}
}
catch(java.io.IOException x)
{
// couldn't start browser
javax.swing.JOptionPane.showMessageDialog(parent, "Could not invoke browser, command=" + browserCommand, "Error", javax.swing.JOptionPane.ERROR_MESSAGE);
}
}
//Determine if operating system is windows
public static boolean isWindowsPlatform()
{
String os = System.getProperty("os.name");
if ( os != null && os.startsWith(WIN_ID))
return true;
else
return false;
}
// Used to identify the windows platform.
private static final String WIN_ID = "Windows";
// Default browser under windows.
private static final String WIN_PATH = "rundll32";
// Flag to display a url.
private static final String WIN_FLAG = "url.dll,FileProtocolHandler";
// Default browser under unix.
private static final String UNIX_PATH = "netscape";
}
// CLASSIFICATION: UNCLASSIFIED
|