import java.lang.reflect.Method;
/**
- * BrowserLauncher is a class that provides one static method, openURL, which
- * opens the default web browser for the current user of the system to the given
- * URL. It may support other protocols depending on the system -- mailto, ftp,
+ * BrowserLauncher is a class that provides two static methods:
+ *
+ * openURL(String url), which opens the default web browser for the current user
+ * of the system to the given URL, and
+ *
+ * resetBrowser(), which allows switching browsers in Java.
+ *
+ * openURL may support other protocols depending on the system -- mailto, ftp,
* etc. -- but that has not been rigorously tested and is not guaranteed to
* work.
* <p>
* "mailto:ejalbert@cs.stanford.edu">ejalbert@cs.stanford.edu</a>)
* @version 1.4b1 (Released June 20, 2001)
*/
+/*
+ *
+ * SwingJS note: Do not use methods in this class directly. Use
+ *
+ * Platform.openURL(String url) only.
+ *
+ * JavaScript does not see this class.
+ */
public class BrowserLauncher
{
/**
private static boolean loadedWithoutErrors;
/** The com.apple.mrj.MRJFileUtils class */
- private static Class mrjFileUtilsClass;
+ private static Class<?> mrjFileUtilsClass;
/** The com.apple.mrj.MRJOSType class */
- private static Class mrjOSTypeClass;
+ private static Class<?> mrjOSTypeClass;
/** The com.apple.MacOS.AEDesc class */
- private static Class aeDescClass;
+ private static Class<?> aeDescClass;
/** The <init>(int) method of com.apple.MacOS.AETarget */
- private static Constructor aeTargetConstructor;
+ private static Constructor<?> aeTargetConstructor;
/** The <init>(int, int, int) method of com.apple.MacOS.AppleEvent */
- private static Constructor appleEventConstructor;
+ private static Constructor<?> appleEventConstructor;
/** The <init>(String) method of com.apple.MacOS.AEDesc */
- private static Constructor aeDescConstructor;
+ private static Constructor<?> aeDescConstructor;
/** The findFolder method of com.apple.mrj.MRJFileUtils */
private static Method findFolder;
*/
static
{
+
loadedWithoutErrors = true;
String osName = System.getProperty("os.name");
*/
private static boolean loadClasses()
{
+
switch (jvm)
{
case MRJ_2_0:
try
{
- Class aeTargetClass = Class.forName("com.apple.MacOS.AETarget");
- Class osUtilsClass = Class.forName("com.apple.MacOS.OSUtils");
- Class appleEventClass = Class.forName("com.apple.MacOS.AppleEvent");
- Class aeClass = Class.forName("com.apple.MacOS.ae");
+ Class<?> aeTargetClass = Class.forName("com.apple.MacOS.AETarget");
+ Class<?> osUtilsClass = Class.forName("com.apple.MacOS.OSUtils");
+ Class<?> appleEventClass = Class
+ .forName("com.apple.MacOS.AppleEvent");
+ Class<?> aeClass = Class.forName("com.apple.MacOS.ae");
aeDescClass = Class.forName("com.apple.MacOS.AEDesc");
aeTargetConstructor = aeTargetClass
try
{
- Class linker = Class.forName("com.apple.mrj.jdirect.Linker");
- Constructor constructor = linker
+ Class<?> linker = Class.forName("com.apple.mrj.jdirect.Linker");
+ Constructor<?> constructor = linker
.getConstructor(new Class[]
{ Class.class });
linkage = constructor
break;
}
-
return browser;
}
*/
public static void openURL(String url) throws IOException
{
+ if (Platform.isJS())
+ {
+ Platform.openURL(url);
+ return;
+ }
if (!loadedWithoutErrors)
{
throw new IOException(MessageManager
break;
default:
-
// This should never occur, but if it does, we'll try the simplest thing
// possible
Runtime.getRuntime().exec(new String[] { (String) browser, url });
-
break;
}
}
+
/**
* Methods required for Mac OS X. The presence of native methods does not
* cause any problems on other platforms.