// Program to demonstrate integer counting triggered by pushing a button import java.awt.*; import java.awt.event.*; public class Count extends java.applet.Applet implements ActionListener { TextField mQuery,mAnsStu, mAnsFac, mAnsSta, mTotal; Button bCount; int noTotal = 0; public void init () { mQuery = new TextField(80); mQuery.setText("Keep track of attendance by pushing the button."); bCount = new Button("Register"); mTotal = new TextField(40); bCount.addActionListener(this); add(mQuery) ; add(bCount) ; add(mTotal) ; mTotal.setText("The total attendance is " + noTotal); } public void actionPerformed(ActionEvent event) { Object cause = event.getSource(); if (cause == bCount) { noTotal = noTotal + 1; mTotal.setText("The total attendance is " + noTotal + " "); } } }