I am trying to use gwt to create a text field and a counter below it with a character length, but it does not take into account the inverse space and with 1 character has a length of 0. Here is my code. What could be the problem?
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); }
source share