1 36 37 40 41 import java.awt.*; 42 import java.awt.event.*; 43 import java.net.*; 44 import java.applet.*; 45 import javax.swing.*; 46 47 50 public class SwingApplet extends JApplet { 51 52 JButton button; 53 54 public void init() { 55 56 String laf = UIManager.getSystemLookAndFeelClassName(); 58 try { 59 UIManager.setLookAndFeel(laf); 60 } catch (UnsupportedLookAndFeelException exc) { 64 System.err.println("Warning: UnsupportedLookAndFeel: " + laf); 65 } catch (Exception exc) { 66 System.err.println("Error loading " + laf + ": " + exc); 67 } 68 69 getContentPane().setLayout(new FlowLayout()); 70 button = new JButton("Hello, I'm a Swing Button!"); 71 getContentPane().add(button); 72 } 73 74 public void stop() { 75 if (button != null) { 76 getContentPane().remove(button); 77 button = null; 78 } 79 } 80 } 81 82 83 | Popular Tags |