Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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]

Answers were Sorted based on User's Feedback



What is the code inside the public void actionPerformed(ActionEvent ae) override method in Applet ..

Answer / 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

What is the code inside the public void actionPerformed(ActionEvent ae) override method in Applet ..

Answer / santoshi

import java.io.*;
import javax.swing.*;
import java.awt.*;
import java.awt.Color.*;
import java.event.*;
class Mypro
{
JFrame jf;
JPanel jp;
Jlabel jl;
JTextField tf;
JButton jb;
public static void main(String n[])
{
Mypro m=new Mypro();
}
public Mypro()
{
jf=new JFrame("MY own");
jp=new JPanel();
jf.add(jp);
jl=new JLabel("enter the color");
jp.add(jl);
tf=new JTextField(8);
jp.add(jf);
jb= new JButton("clikc");
jp.add(jb);
jf.setVisible(true);
jf.setSize(500,500);
}
public void actionPerformed(actionEvent ae)
{
Object o=ae.getSource();
String gt=tf.getText();
if(o==jb)
{
if(gt=="red")
setBackground(Color.red);
if(gt=="yellow")
setBackground(Color.yellow);
}
}
}

Is This Answer Correct ?    7 Yes 2 No

Post New Answer

More Core Java Interview Questions

What is the difference between the paint() and repaint() methods?

0 Answers  


What is void in java?

0 Answers  


What is the difference between numeric and integer?

0 Answers  


how to create daemon thread in java?

0 Answers  


How can two threads be made to communicate with each other?

3 Answers   HCL,


Can static method access instance variables ?

0 Answers  


How many bits is a char?

0 Answers  


Can you extend main method in java?

0 Answers  


When wait(), notify(), notifyall() methods are called does it releases the lock or holds the acquired lock?

0 Answers  


What does java final mean?

0 Answers  


explain about jre and jvm

2 Answers  


Do loops java?

0 Answers  


Categories