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
What is import java util arraylist?
Difference between abstract and concrete class ?
Is object a data type?
Why java applets are more useful for intranets as compared to internet?
what is the use of pojo (plain old java objects)? how it is interact with crystal reports? pls urgent
Explain about member inner classes?
What is the difference between int and integer in java?
Define Multiprogramming and Multiprocessing in java.
Convert a BST into a DLL and DLL to BST in place.
What best practices should you follow while writing multithreaded code in java?
Does java allow overriding static methods ?
Can we rethrow the same exception from catch handler?
What is the difference between jfc & wfc?
What is meant by final class?
What do you understand by copy constructor in java?