Detect if Swing is installed (this howto is deprecated)Tag(s): DEPRECATED


public class SwingSniffer extends java.applet.Applet {
  public void init() {  
    try {
      com.sun.java.swing.JButton dummy = 
          new com.sun.java.swing.JButton("foo");
      System.out.println("Swing is here"); 
      // getAppletContext().showDocument
      // (new URL(getCodeBase()+"AppletPageWithNoArchiveTag.html"));
      } 
    catch(Exception e) {
      System.out.println
         ("Swing is not here, you must download or install it");    
      // getAppletContext().showDocument
      // (new URL(getCodeBase()+"AppletPageWithArchiveTag.html"));
      }
    } 
}
<HTML><HEAD></HEAD><BODY>
<APPLET CODE="SwingSniffer.class"  
      HEIGHT=1 WIDTH=1>
 <A HREF="/nojava.html">
   Oups! You don't have JAVA enabled, click here.</A>        
</APPLET>
</BODY></HTML>

blog comments powered by Disqus