Edit Draft  [ No Subject ]
...Full View
Photo for Ieva V
From:	
Ieva V <vilkdagiss@yahoo.com>  [Chat now]
...
View Contact
To:	 	
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

 public class Applet extends JApplet {
    int count=0;
      private ActionListener bli = new ActionListener()
      {
 
   public void actionPerformed(ActionEvent e) {
  //   String count = ((JButton)e.getSource()).getText();
     count++;
     txt.setText(""+count);
   }
 };
 
 private ActionListener bli2 = new ActionListener()
      {
    //  int count=0;
   public void actionPerformed(ActionEvent e) {
     count--;
     txt.setText(""+count);
   }
 };
 private JButton
     button1 = new JButton("Button1"),
     button2 = new JButton("Button2");
   private JTextField txt = new JTextField(10);
 public void init() {
    button1.addActionListener(bli);
    button2.addActionListener(bli2);
    Container cp = getContentPane();
    cp.setLayout(new FlowLayout());
    cp.add(button1);
    cp.add(button2);
    cp.add(txt);
 }

 public static void main(String[] args){
   JApplet applet = new Applet();
    JFrame frame = new JFrame("Applet");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(applet);
   frame.setSize(200,200);
        applet.init();
     applet.start();
    frame.setVisible(true);

       }

   }

 /*<applet code=AnApplet.class width=200 height=200>
</applet>
*/

