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

Practical-13 Develop a program to present a set of choice for user to select a product and display the price of product.

Write a program to increase and decrease font size programmatically.