import java.awt.*; import java.awt.event.*; import javax.swing.*; /** A VERY simple example of an applet that doesn't do much. @author Sudarshan S. Chawathe */ public class A2 extends JApplet implements ActionListener { public void init() { Container p = getContentPane(); p.setBackground(Color.white); p.setLayout(new FlowLayout()); topLabel = new JLabel(topLabelString); p.add(topLabel); inputTextField = new JTextField(40); p.add(inputTextField); goButton = new JButton("Go"); goButton.addActionListener(this); p.add(goButton); pBar = new JProgressBar(0, 100); p.add(pBar); outputTextField = new JTextField(50); outputTextField.setEditable(false); p.add(outputTextField); } public void start() { } public void stop() { } public void destroy() { } public void actionPerformed(ActionEvent e) { if(progress < 100) { progress += 5; pBar.setValue(progress); outputTextField.setText("Thinking... " + progress + "%. Click Go for more!"); } else { outputTextField.setText(inputTextField.getText() + doneString); progress = 0; pBar.setValue(progress); } } private static final long serialVersionUID = 8617755644768825405L; private JLabel topLabel; private JButton goButton; private JTextField inputTextField; private JTextField outputTextField; private JProgressBar pBar; private int progress; private static final String topLabelString = " Maine driving directions
" + "Enter your destination and click Go. "; private static final String doneString = "? Now that I think about it, you can't get there from here!"; }