home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 March / pcp161a.iso / handson / files / java / ColourDemo.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-11-28  |  1.2 KB  |  21 lines

  1. import com.sun.java.swing.JApplet;
  2. import com.sun.java.swing.JButton;
  3. import com.sun.java.swing.preview.JColorChooser;
  4. import java.awt.Color;
  5. import java.awt.event.ActionEvent;
  6. import java.awt.event.ActionListener;
  7.  
  8. public class ColourDemo extends JApplet implements ActionListener {
  9.    private JButton btnChange;
  10.  
  11.    public void init() {
  12.       this.btnChange = new JButton("Click to change my colour!");
  13.       this.btnChange.addActionListener(this);
  14.       ((JApplet)this).getContentPane().add(this.btnChange);
  15.    }
  16.  
  17.    public void actionPerformed(ActionEvent var1) {
  18.       this.btnChange.setBackground(JColorChooser.showDialog(this, "ColourDemo's colour chooser", Color.white));
  19.    }
  20. }
  21.