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
Why do we override tostring method in java?
What is immutable state?
Can we call a non-static method from inside a static method?
When is update method called?
What is primitive data type in java?
What is comparable and comparator interface? List their differences
What are some examples of variable costs?
I want to re-reach and use an object once it has been garbage collected. Define how it’s possible?
Does java support multiple inheritance or not?
What is boolean logic?
Is boolean a wrapper class in java?
What java ide should I use?
what is thread? What are the high-level thread states? Or what are the states associated in the thread? : Java thread
Can a class have multiple constructors?
What are the differences between stringbuffer and stringbuilder?