You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

InputPromptAndCursorPosition.java 1.1KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package com.vaadin.tests.components.textfield;
  2. import com.vaadin.server.VaadinRequest;
  3. import com.vaadin.tests.components.AbstractReindeerTestUI;
  4. import com.vaadin.ui.Button;
  5. import com.vaadin.ui.Label;
  6. import com.vaadin.ui.TextField;
  7. public class InputPromptAndCursorPosition extends AbstractReindeerTestUI {
  8. @Override
  9. protected void setup(VaadinRequest request) {
  10. final TextField tf = new TextField();
  11. tf.setWidth("40em");
  12. tf.setValue(
  13. "Delete this text to reveal input prompt and update cursor position.");
  14. tf.setPlaceholder("This is an input prompt");
  15. final Label l = new Label("Cursor position: ?");
  16. Button button = new Button("Update cursor position", event -> l
  17. .setValue("Cursor position: " + tf.getCursorPosition()));
  18. addComponent(tf);
  19. addComponent(l);
  20. addComponent(button);
  21. }
  22. @Override
  23. protected String getTestDescription() {
  24. return "Cursor position should always be zero when input prompt is displayed.";
  25. }
  26. @Override
  27. protected Integer getTicketNumber() {
  28. return 19766;
  29. }
  30. }