Practical-5 Develop an applet that contains one button. Initialize the label on the button to “start”, when the user presses the button, which changes the label between these two values each time the button is pressed.

 

import java.applet.*;

import java.awt.*;

import java.awt.event.*;

public class Practical5 extends Applet implements ActionListener {

    Button b;

    public void init() {

        b=new Button("Start");

        b.addActionListener(this);

        add(b);

    }

    public void actionPerformed(ActionEvent e)

    {

        if(b.getLabel()=="Start")

        {

            b.setLabel("Stop");

        }

        else

        {

            b.setLabel("Start");

        }

    }

}

Output:






Comments

Popular posts from this blog

Mandavrayji Temple, Muli, Surendranagar, Gujarat

Write a program to check whether empty query string is entered in Asp.Net.

Write a program to change color of Label text control programmatically in Asp.Net.