private void fillPerson()
{
try
{
this.selectedPerson=new PersonController().getOne(NuInt.safeParse((this.txtIdPerson.getText())));
if(this.selectedPerson.getId()!=0)
{
this.txtPersonName.setText(this.selectedPerson.getName());
this.txtZoneName.setText(this.selectedPerson.getZona().getName());
this.txtCompanyName.setText(this.selectedPerson.getCompany().getName());
}
else
{
this.txtPersonName.setText("");
this.txtZoneName.setText("");
this.txtCompanyName.setText("");
this.txtIdPerson.requestFocus(); <------------------------------------------------------------------------ This produces the dual focus
}
}
private class FocusListener implements ChangeListener<Boolean>
{
private TripFrmController trip;
public FocusListener(TripFrmController Trip)
{
this.trip=trip;
}
@Override
public void changed(ObservableValue<? extends Boolean> ov, Boolean prevVal, Boolean newVal)
{
if (!newVal)
{
this.trip.fillPerson();
}
}
}
This code makes two TextField controls get focus at the same time.
Screenshot of the result:
http://i.stack.imgur.com/RszF9.png
{
try
{
this.selectedPerson=new PersonController().getOne(NuInt.safeParse((this.txtIdPerson.getText())));
if(this.selectedPerson.getId()!=0)
{
this.txtPersonName.setText(this.selectedPerson.getName());
this.txtZoneName.setText(this.selectedPerson.getZona().getName());
this.txtCompanyName.setText(this.selectedPerson.getCompany().getName());
}
else
{
this.txtPersonName.setText("");
this.txtZoneName.setText("");
this.txtCompanyName.setText("");
this.txtIdPerson.requestFocus(); <------------------------------------------------------------------------ This produces the dual focus
}
}
private class FocusListener implements ChangeListener<Boolean>
{
private TripFrmController trip;
public FocusListener(TripFrmController Trip)
{
this.trip=trip;
}
@Override
public void changed(ObservableValue<? extends Boolean> ov, Boolean prevVal, Boolean newVal)
{
if (!newVal)
{
this.trip.fillPerson();
}
}
}
This code makes two TextField controls get focus at the same time.
Screenshot of the result:
http://i.stack.imgur.com/RszF9.png
- duplicates
-
JDK-8115909 [Focus] if traverse focus in focus change listener, scene will have two focused controls
- Closed