1.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.

StartStop.java

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
/*
<applet code="StartStop.class" height=400 width=800>
</applet>
*/
public class StartStop extends Applet implements ActionListener
{
Button btn;
public void init()
{
btn=new Button("Start");
btn.addActionListener(this);
add(btn);
}
public void actionPerformed(ActionEvent ae)
{
if(btn.getLabel()=="Start")
{
btn.setLabel("Stop");
}
else
{
btn.setLabel("Start");
}
}
}

Output


Run code to see proper output

Happy Coding :)