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
Can we change the value of static variable?
How can you read an integer value from the keyword when the application is runtime in java? example?
What is sleep method?
Which collection is best for sorting in java?
What are the types of web technologies?
Where can i get Latest SUN Certification Dumps and what are the Sun Certification Codes that are available, Im new to JAVA, so please gimme info as i need to write J2EE - Core Java Certification
What is field name?
What is an array in java?
How the interruptible method gets implemented?
Why are parameters used in functions?
What is a flag value?
Is the milky way in a void?
Is double bigger than float?
why are wait(), notify() and notifyall() methods defined in the object class? : Java thread
Does sprintf allocate memory?