home *** CD-ROM | disk | FTP | other *** search
/ Australian PC Authority 1999 May / may1999.iso / May / JBUILDER / JSAMPLES.Z / SwingApplet.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-04-30  |  1.5 KB  |  34 lines

  1. import com.sun.java.swing.JApplet;
  2. import com.sun.java.swing.JButton;
  3. import com.sun.java.swing.UIManager;
  4. import com.sun.java.swing.UnsupportedLookAndFeelException;
  5. import java.awt.FlowLayout;
  6.  
  7. public class SwingApplet extends JApplet {
  8.    JButton button;
  9.  
  10.    public void init() {
  11.       String var1 = UIManager.getSystemLookAndFeelClassName();
  12.  
  13.       try {
  14.          UIManager.setLookAndFeel(var1);
  15.       } catch (UnsupportedLookAndFeelException var3) {
  16.          System.err.println("Warning: UnsupportedLookAndFeel: " + var1);
  17.       } catch (Exception var4) {
  18.          System.err.println("Error loading " + var1 + ": " + var4);
  19.       }
  20.  
  21.       ((JApplet)this).getContentPane().setLayout(new FlowLayout());
  22.       this.button = new JButton("Hello, I'm a Swing Button!");
  23.       ((JApplet)this).getContentPane().add(this.button);
  24.    }
  25.  
  26.    public void stop() {
  27.       if (this.button != null) {
  28.          ((JApplet)this).getContentPane().remove(this.button);
  29.          this.button = null;
  30.       }
  31.  
  32.    }
  33. }
  34.