gwtを使用して、文字の長さでテキストエリアとカウンタを作成しようとしましたが、バックスペースをカウントせず、1文字の長さは0です。何が問題なの?GWT TextAreaリスナー
public class Test implements EntryPoint {
TextArea textArea;
Label counter;
public void onModuleLoad() {
textArea = new TextArea();
counter = new Label("Number of characters: 0");
textArea.addKeyPressHandler(new KeyPressHandler() {
public void onKeyPress(KeyPressEvent event) {
counter.setText("Number of characters: " + textArea.getText().length());
}
});
RootPanel.get("myContent").add(textArea);
RootPanel.get("myContent").add(counter);
}
が、これは働いている、ありがとうございます。 –