CountDown
CountDownApplet.java
/**
* CountDownApplet.java
* Written By Chuck Cusack
* October, 2005
*
* A simple applet that counts down.
* See CountDown.java for more details.
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class CountDownApplet extends JApplet {
javax.swing.Timer timer;
CountDown cd;
boolean pressed=false;
// This is used to set up the applet
public void init() {
putItOn(this.getContentPane());
}
// This is used if you want to run it as an application
public static void main(String[] args) {
JFrame frame=new JFrame();
frame.setTitle("Count Down");
putItOn(frame.getContentPane());
frame.pack();
frame.setSize(new Dimension(200,200));
frame.setVisible(true);
}
// This puts the important stuff on the contentPane.
public static void putItOn(Container cont) {
CountDown cd=new CountDown();
cont.add(cd,BorderLayout.CENTER);
JButton button=new JButton("Start");
button.addActionListener(cd);
cont.add(button,BorderLayout.SOUTH);
}
}
|