gt:  	catch (Exception e) {  // do not not complain
context: /*
   * Open Source Physics software is free software as described near the bottom of this code file.
   *
   * For additional information and documentation on Open Source Physics please see:
   * <http://www.opensourcephysics.org/>
   */
  
  package org.opensourcephysics.display;
  import java.awt.Component;
  import java.awt.event.InputEvent;
  import java.awt.event.MouseEvent;
  import java.io.File;
  import java.io.IOException;
  import java.lang.reflect.Method;
  import java.net.JarURLConnection;
  import java.net.URL;
  import java.util.ArrayList;
  import java.util.Enumeration;
  import java.util.HashMap;
  import java.util.Locale;
  import java.util.jar.JarEntry;
  import java.util.jar.JarFile;
  import javax.swing.JApplet;
  import javax.swing.JDialog;
  import javax.swing.JFileChooser;
  import javax.swing.JFrame;
  import javax.swing.JOptionPane;
  import javax.swing.LookAndFeel;
  import javax.swing.UIManager;
  import javax.swing.plaf.metal.MetalLookAndFeel;
  
  import org.opensourcephysics.controls.OSPLog;
  import org.opensourcephysics.controls.XML;
  import org.opensourcephysics.tools.ResourceLoader;
  import org.opensourcephysics.tools.Translator;
  
  /**
   * This class defines static methods related to the runtime environment.
   *
   * @author Douglas Brown
   * @author Wolfgang Christian
   * @version 1.0
   */
  public class OSPRuntime {
    static String version = "2.3";                                                                            //$NON-NLS-1$
    static String releaseDate = "May 31, 2011";                                                           //$NON-NLS-1$
  
    /** Disables drawing for faster start-up and to avoid screen flash in Drawing Panels. */
    volatile public static boolean disableAllDrawing = false;
  
    /** Load Video Tool, if available. */
    public static boolean loadVideoTool = true;
  
    /** Load Export Tool, if available. */
    public static boolean loadExportTool = true;
  
    /** Load Data Tool, if available. */
    public static boolean loadDataTool = true;
  
    /** Load Fourier Tool, if available. */
    public static boolean loadFourierTool = true;
  
    /** Load Translator Tool, if available. */
    public static boolean loadTranslatorTool = true;
  
    /** Load OSP Log, if available. */
    public static boolean loadOSPLog = true;
  
    /** Shared Translator after loading, if available. */
    private static Translator translator;                                                                     // shared Translator
  
    /** Array of default OSP Locales. */
    public static Locale[] defaultLocales = new Locale[] {Locale.ENGLISH, new Locale("es"), new Locale("de"), //$NON-NLS-1$ //$NON-NLS-2$
      new Locale("da"), new Locale("sk"), Locale.TAIWAN};                                                       //$NON-NLS-1$ //$NON-NLS-2$
  
    /** Set <I>true</I> if a program is being run within Launcher. */
    protected static boolean launcherMode = false;
  
    /** True if text components should try and anti-alias text. */
    public static Boolean antiAliasText = false;
  
    /** True if running as an applet. */
    public static boolean appletMode;
  
    /** Static reference to an applet for document/code base access. */
    public static JApplet applet;
  
    /** True if launched by WebStart. */
    public static boolean webStart;
    
    /** True if launched by WebStart. */
  //  public static boolean J3D;
  
    /** True if users allowed to author internal parameters such as Locale strings. */
    protected static boolean authorMode = true;
  
    /** Path of the launch jar, if any. */
    static private String launchJarPath;
  
    /** Path of the launch jar, if any. */
    static private String launchJarName;
  
    /** The launch jar, if any. */
    static private JarFile launchJar = null;
  
    /** Build date of the launch jar, if known. */
    static private String buildDate;
  
    /** File Chooser starting directory. */
    public static String chooserDir;
  
    /** Location of OSP icon. */
    public static final String OSP_ICON_FILE = "/org/opensourcephysics/resources/controls/images/osp_icon.gif"; //$NON-NLS-1$
  
    /** True if always launching in single vm (applet mode, etc). */
    public static boolean launchingInSingleVM;
    // look and feel types
    @SuppressWarnings("javadoc")
  	public final static String CROSS_PLATFORM_LF = "CROSS_PLATFORM";                    //$NON-NLS-1$
    @SuppressWarnings("javadoc")
  	public final static String NIMBUS_LF = "NIMBUS";                                    //$NON-NLS-1$
    @SuppressWarnings("javadoc")
  	public final static String SYSTEM_LF = "SYSTEM";                                    //$NON-NLS-1$
    @SuppressWarnings("javadoc")
  	public final static String METAL_LF = "METAL";                                      //$NON-NLS-1$
    @SuppressWarnings("javadoc")
  	public final static String GTK_LF = "GTK";                                          //$NON-NLS-1$
    @SuppressWarnings("javadoc")
  	public final static String MOTIF_LF = "MOTIF";                                      //$NON-NLS-1$
    @SuppressWarnings("javadoc")
  	public final static String WINDOWS_LF = "WINDOWS";                                  //$NON-NLS-1$
    @SuppressWarnings("javadoc")
  	public final static String DEFAULT_LF = "DEFAULT";                                  //$NON-NLS-1$
    @SuppressWarnings("javadoc")
  	public final static LookAndFeel DEFAULT_LOOK_AND_FEEL = UIManager.getLookAndFeel(); // save the default before we change LnF
    @SuppressWarnings("javadoc")
  	public final static boolean DEFAULT_LOOK_AND_FEEL_DECORATIONS = JFrame.isDefaultLookAndFeelDecorated();
    @SuppressWarnings("javadoc")
  	public final static HashMap<String, String> LOOK_AND_FEEL_TYPES = new HashMap<String, String>();
  
    /**
     * Sets default properties for OSP.
     */
    static {
      //java.util.Locale.setDefault(new java.util.Locale("es"));  // test of language resources       
      //setLookAndFeel(true, CROSS_PLATFORM_LF);                  // test of LnF
      //setLookAndFeel(true, SYSTEM_LF);                  // test of LnF
      try { // sets the default directory for the chooser                                                                             // system properties may not be readable in some contexts
        OSPRuntime.chooserDir = System.getProperty("user.dir", null);                            //$NON-NLS-1$
      } catch(Exception ex) {
        OSPRuntime.chooserDir = null;
      }
      // fill the look and feel map
      LOOK_AND_FEEL_TYPES.put(METAL_LF, "javax.swing.plaf.metal.MetalLookAndFeel");              //$NON-NLS-1$
      LOOK_AND_FEEL_TYPES.put(NIMBUS_LF, "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");    //$NON-NLS-1$
      LOOK_AND_FEEL_TYPES.put(GTK_LF, "com.sun.java.swing.plaf.gtk.GTKLookAndFeel");             //$NON-NLS-1$
      LOOK_AND_FEEL_TYPES.put(MOTIF_LF, "com.sun.java.swing.plaf.motif.MotifLookAndFeel");       //$NON-NLS-1$
      LOOK_AND_FEEL_TYPES.put(WINDOWS_LF, "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); //$NON-NLS-1$
      LOOK_AND_FEEL_TYPES.put(CROSS_PLATFORM_LF, UIManager.getCrossPlatformLookAndFeelClassName());
      LOOK_AND_FEEL_TYPES.put(SYSTEM_LF, UIManager.getSystemLookAndFeelClassName());
      LOOK_AND_FEEL_TYPES.put(DEFAULT_LF, DEFAULT_LOOK_AND_FEEL.getClass().getName());
  //	try {
  //	  Class.forName("com.sun.j3d.utils.universe.SimpleUniverse"); //$NON-NLS-1$
  //	  J3D= true; 
  //	} catch (NoClassDefFoundError e) { // Do not complain
  //	  J3D=  false; 
  //	} catch (ClassNotFoundException e) {
  //	  J3D=  false; 
  //	}
    }
  
    /**
     * Private constructor to prevent instantiation.
     */
    private OSPRuntime() {
      /** empty block */
    }
  
    /**
     * Shows the about dialog.
     * @param parent 
     */
    public static void showAboutDialog(Component parent) {
      String aboutString = "OSP Library "+version+" released "+releaseDate+"\n"           //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                           +"Open Source Physics Project \n"+"www.opensourcephysics.org"; //$NON-NLS-1$ //$NON-NLS-2$
      JOptionPane.showMessageDialog(parent, aboutString, "About Open Source Physics", JOptionPane.INFORMATION_MESSAGE); //$NON-NLS-1$
    }
  
    /**
     * Sets the look and feel of the user interface.  Look and feel user interfaces are:
     *
     * NIMBUS_LF: com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel
     * METAL_LF: javax.swing.plaf.metal.MetalLookAndFeel
     * GTK_LF: com.sun.java.swing.plaf.gtk.GTKLookAndFeel
     * MOTIF_LF: com.sun.java.swing.plaf.motif.MotifLookAndFeel
     * WINDOWS_LF: com.sun.java.swing.plaf.windows.WindowsLookAndFeel
     * DEFAULT_LF: the default look and feel in effect when this class was loaded
     * CROSS_PLATFORM_LF: the cross platform look and feel; usually METAL_LF
     * SYSTEM_LF: the operating system look and feel
     *
     * @param useDefaultLnFDecorations
     * @param lookAndFeel
     *
     * @return true if successful
     */
    public static boolean setLookAndFeel(boolean useDefaultLnFDecorations, String lookAndFeel) {
      boolean found = true;
      LookAndFeel currentLookAndFeel = UIManager.getLookAndFeel();
      try {
        if((lookAndFeel==null)||lookAndFeel.equals(DEFAULT_LF)) {
          UIManager.setLookAndFeel(DEFAULT_LOOK_AND_FEEL);
          useDefaultLnFDecorations = DEFAULT_LOOK_AND_FEEL_DECORATIONS;
        } else if(lookAndFeel.equals(CROSS_PLATFORM_LF)) {
          lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
          UIManager.setLookAndFeel(lookAndFeel);
        } else if(lookAndFeel.equals(SYSTEM_LF)) {
          lookAndFeel = UIManager.getSystemLookAndFeelClassName();
          UIManager.setLookAndFeel(lookAndFeel);
        } else if(lookAndFeel.equals(NIMBUS_LF)) {
          UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");   //$NON-NLS-1$
        } else if(lookAndFeel.equals(METAL_LF)) {
          //        MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
          UIManager.setLookAndFeel(new MetalLookAndFeel());
        } else if(lookAndFeel.equals(GTK_LF)) {
          UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");         //$NON-NLS-1$
        } else if(lookAndFeel.equals(MOTIF_LF)) {
          UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");     //$NON-NLS-1$
        } else if(lookAndFeel.equals(WINDOWS_LF)) {
          UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); //$NON-NLS-1$
        } else {
          UIManager.setLookAndFeel(lookAndFeel);                                          // LnF can be set using a fully qualified path
        }
        JFrame.setDefaultLookAndFeelDecorated(useDefaultLnFDecorations);
        JDialog.setDefaultLookAndFeelDecorated(useDefaultLnFDecorations);
      } catch(Exception ex) {
        found = false;
      }
      if(!found) { // keep current look and feel
        try {
          UIManager.setLookAndFeel(currentLookAndFeel);
        } catch(Exception e) {}
      }
      return found;
    }
  
    /**
     * Returns true if newly created <code>JFrame</code>s or <code>JDialog</code>s should have their
     * Window decorations provided by the current look and feel. This is only
     * a hint, as certain look and feels may not support this feature.
     *
     * @return true if look and feel should provide Window decorations.
     * @since 1.4
     */
    public static boolean isDefaultLookAndFeelDecorated() {
      return JFrame.isDefaultLookAndFeelDecorated();
    }
  
    /**
     * Determines if OS is Windows
     *
     * @return true if Windows
     */
    public static boolean isWindows() {
      try {                                                                            // system properties may not be readable in some environments
        return(System.getProperty("os.name", "").toLowerCase().startsWith("windows")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      } catch(SecurityException ex) {
        return false;
      }
    }
  
    /**
     * Determines if OS is Mac
     *
     * @return true if Mac
     */
    public static boolean isMac() {
      try {                                                                        // system properties may not be readable in some environments
        return(System.getProperty("os.name", "").toLowerCase().startsWith("mac")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      } catch(SecurityException ex) {
        return false;
      }
    }
  
    /**
     * Determines if OS is Linux
     *
     * @return true if Linux
     */
    public static boolean isLinux() {
      try {                                                                          // system properties may not be readable in some environments
        return(System.getProperty("os.name", "").toLowerCase().startsWith("linux")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      } catch(SecurityException ex) {
        return false;
      }
    }
  
    /**
     * Determines if OS is Vista
     *
     * @return true if Vista
     */
    static public boolean isVista() {
      if(System.getProperty("os.name", "").toLowerCase().indexOf("vista")>-1) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        return true;
      }
      return false;
    }
    
    static public boolean hasJava3D() {
      try{
        if (OSPRuntime.isMac()) {  // extra testing for Mac
          boolean tryIt=true;
          String home = System.getProperty("java.home");//$NON-NLS-1$
          String version = System.getProperty("java.version"); //$NON-NLS-1$
          if (version.indexOf("1.7")<0) tryIt = true; //$NON-NLS-1$
          else tryIt = (new java.io.File(home+"/lib/ext/j3dcore.jar")).exists(); //$NON-NLS-1$
          if (!tryIt) return false;
        }
      } catch (Exception exc) { return false; } // Any problem! Do not complain and quit
      // look for J3D class
   	try {
        Class.forName("com.sun.j3d.utils.universe.SimpleUniverse"); //$NON-NLS-1$
        return true; 
  	} catch (Error e) {  // do not not complain
  		  return false; 
      }
  