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


Please Help Members By Posting Answers For Below Questions

What is import java util arraylist?

866


Difference between abstract and concrete class ?

765


Is object a data type?

750


Why java applets are more useful for intranets as compared to internet?

794


what is the use of pojo (plain old java objects)? how it is interact with crystal reports? pls urgent

1932


Explain about member inner classes?

801


What is the difference between int and integer in java?

762


Define Multiprogramming and Multiprocessing in java.

785


Convert a BST into a DLL and DLL to BST in place.

863


What best practices should you follow while writing multithreaded code in java?

765


Does java allow overriding static methods ?

835


Can we rethrow the same exception from catch handler?

784


What is the difference between jfc & wfc?

791


What is meant by final class?

773


What do you understand by copy constructor in java?

707