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
How do you use parseint in java?
What is nextint java?
What is the purpose of garbage collection in java? When is it used?
which one is more efficient int x; 1. if(x==null) 2.if(null==x) state which one either 1 or 2?
Difference between a process and a program?
Is array a class in java?
What are the advantages of inner classes?
Why scanner is used in java?
What are the three best choices for a development environment?
What are wrapper classes in java?
What value is a variable of the string type automatically initialized?
In a container there are 5 components. I want to display the all the components names, how will you do that one?
Is it compulsory for a try block to be followed by a catch block in java for exception handling?
Differentiate between overriding and overloading cases?
What is the multi-catch block in java?