The following applet contains a Textfield. The FocusListener for the field should write the field’s name and the name of the FocusEvent to the console. Using an appletviewer or browser it works as expected. Embedded in a notesform (client version 6.5.2), it seems the FocusGained-Event is never fired. The only message at the javaconsole is “Field1 lost focus” when the focus is moved from the applet to a notesfield. Does anybody know the secrets of managing focusevents in notes-applets?
public class Test extends JApplet {
public void init(){
JTextField t1=new JTextField(15);
t1.setName(“Field1”);
t1.addFocusListener(new MyFocusListener());
JButton b1=new JButton(“do nothing”);
getContentPane().setLayout(new FlowLayout());
getContentPane().add(t1);
getContentPane().add(b1);
}
private class MyFocusListener implements FocusListener {
public void focusGained(FocusEvent e) {
JTextField jtf=(JTextField) e.getSource();
System.out.println(jtf.getName()+ " got Focus");
}
public void focusLost(FocusEvent e) {
JTextField jtf=(JTextField) e.getSource();
System.out.println(jtf.getName()+ " lost Focus");
}
}
}