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 which version of Swing is installed


Author: Davanum Srinivas
Author's WebSite: http://dims.someone.net/

This Code can be compiled with any version of Java. It checks which version of Swing is installed.


public class SwingSniffer extends java.applet.Applet 
{
   public void init() {  
     Class swingOldJButtonClass = null;
     Class swingNewJButtonClass = null;
     // Try to check for the Old Version of Swing
     try {
       swingOldJButtonClass = Class.forName("com.sun.java.swing.JButton");
       if(swingOldJButtonClass != null)
	       System.out.println("Old Version of Swing is present"); 
       } 
     catch(NoClassDefFoundError e) {
       }
     catch(ClassNotFoundException e) {
       }
     // Try to check for the New Version of Swing
     try {
       swingNewJButtonClass = Class.forName("javax.swing.JButton");
       if(swingNewJButtonClass != null)
	       System.out.println("New Version of Swing is present"); 
       } 
     catch(NoClassDefFoundError e) {
       }
     catch(ClassNotFoundException e) {
       }
     // Print Message if both are absent.
       if(swingOldJButtonClass == null && swingNewJButtonClass == null)
	       System.out.println("Swing Absent"); 
     } 
 }




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>

Posted On: 8-Jul-1999

internet.commerce
Partner With Us
Promote Your Website
Best Price
Logo Design
Web Design
Promotional Items
Compare Prices
KVM over IP
PDA Phones & Cases
Server Racks
Desktop Computers
Promotional Products
Promotional Golf
Free Business Cards
Promos and Premiums



Acceptable Use Policy

JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers