alessalessio
8 Apr 2011, 7:07 AM
I actually decides to open a thread about this argument, since i experienced it is not working as i imagined,and read many post about this but found no clear solution.
The problem statement is quite simple:
Have a form panel and Fields within it, how can i set the focus onto a field?
The next two simple code does not do the job:
1)
TextField tf = new TextField<String>();
Button button = new Button("focus on textfield");
button.addSelectionListener(new SelectionListener<ButtonEvent>(){
@Override
public void componentSelected(ButtonEvent ce) {
tf.setFocus();
}
});
2)
TextField tf = new TextField<String>();
Window window = new Window();
window.add(tf);
window.setFocusWidget(tf);
What am i doing wrong?
The problem statement is quite simple:
Have a form panel and Fields within it, how can i set the focus onto a field?
The next two simple code does not do the job:
1)
TextField tf = new TextField<String>();
Button button = new Button("focus on textfield");
button.addSelectionListener(new SelectionListener<ButtonEvent>(){
@Override
public void componentSelected(ButtonEvent ce) {
tf.setFocus();
}
});
2)
TextField tf = new TextField<String>();
Window window = new Window();
window.add(tf);
window.setFocusWidget(tf);
What am i doing wrong?