EarthWeb
Developer.com
Site
windows 2000
visual c++
java
visual basic
javascripts
recommend it
 
Book
thinking in java
 
Interact
forum
guest book
jobs
jokes
what's new

share code
 
Resource
add resource
modify resource
new resource
 

[Internet Jobs]
-----
Java by E-mail:

Get the weekly e-mail highlights on Java!
-----

-

Detect if Swing is installed


Author: Real Gagnon
Author's WebSite: http://tactika.com/realhome/realhome.html


 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(NoClassDefFoundError e) {
       System.out.println("Swing is not here, you must download or install it");    
       // getAppletContext().showDocument
       // (new URL(getCodeBase()+"AppletPageWithArchiveTag.html"));
       }
     } 
 }



NOTE: With the JDK1.2 release, it's recommended to use


 import javax.swing.*;

instead of


 import com.sun.java.swing.*;



<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>

Posted On: 5-Jul-1999

internet.commerce



Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy