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 many types of variables are there?
What is array length?
Explain different types of thread priorities ?
Why does java not allow multiple public classes in a java file ?
Can you use this() and super() both in a constructor?
How use .contains in java?
What are the main differences between the java platform and other platforms?
What best practices should you follow while writing multithreaded code in java?
What is a lightweight component?
What are parsers? Dom vs sax parser.
How do you reverse sort a list in java?
What are reference variables in java?
what is thread in Java ?
What is autoboxing and unboxing?
What is use of static method?