Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

FocusListner

  Asked By: Jasmine    Date: Jul 22    Category: Java    Views: 495
  

I got a piece of code like this


Jtextfield one=new Jtextfield("",3);
one.addFocusListener(this);

Jtextfield two=new Jtextfield("",4);
two.addFocusListener(this);

private void focusLost(FocusEvent fe)
{
// to do
}

How do i get the name of the textfield that triggered the focus event

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Wilbur Hall     Answered On: Jul 22

Jtextfield one=new Jtextfield("",3);
one.setName("one")
one.addFocusListener(this);


Jtextfield two=new Jtextfield("",4);
two.setName("two")
two.addFocusListener(this);

private void  focusLost(FocusEvent fe)
{
String name = ((Component)fe.getSource()).getName();
}

 
Didn't find what you were looking for? Find more on FocusListner Or get search suggestion and latest updates.

Related Topics:



Tagged:  

 
 
 
 

Related Post