What is the code inside the public void
actionPerformed(ActionEvent ae) override method in Applet
[ Condition:- you have one TextField and One Button , you
have to enter any color name inside the TextField, when you
click on Button Your background will change according to
your input color name]
Answer Posted / sriharsha gowda
public void actionPerformed(ActionEvent ae)
{
String str=ae.getActionCommand();
if(ae.getSource()==b1) setBackground(Color.yellow);
if(ae.getSource()==b2) setBackground(Color.blue);
if(ae.getSource()==b3) setBackground(Color.pink);
}
The above code can be used whenever we have different buttons and when any button is clicked its color changes accordingly
| Is This Answer Correct ? | 8 Yes | 2 No |
Post New Answer View All Answers
Which is better list or arraylist in java?
Explain how can you debug the Java code?
What java is used for?
What is data type in computer?
What is io stream in java?
What are recursive functions?
What is empty string literal in java?
What is a modifier?
What is difference between adapter class and listener?
What is a local, member and a class variable?
Is int primitive data type?
What is private static class in java?
How do you sort data in java?
Is special character in java?
How to Sort Strings which are given in List and display in ascending order without using java api.