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.

Ticket5053.java 934B

1234567891011121314151617181920212223242526272829303132333435
  1. package com.vaadin.tests.tickets;
  2. import com.vaadin.server.LegacyApplication;
  3. import com.vaadin.ui.ComboBox;
  4. import com.vaadin.ui.LegacyWindow;
  5. /**
  6. * #5053: Last ComboBox item may not be shown if null selection enabled
  7. */
  8. public class Ticket5053 extends LegacyApplication {
  9. @Override
  10. public void init() {
  11. LegacyWindow main = new LegacyWindow();
  12. setMainWindow(main);
  13. ComboBox combobox = new ComboBox("My ComboBox");
  14. // Enable null selection
  15. combobox.setNullSelectionAllowed(true);
  16. // Add the item that marks 'null' value
  17. String nullitem = "-- none --";
  18. combobox.addItem(nullitem);
  19. // Designate it was the 'null' value marker
  20. combobox.setNullSelectionItemId(nullitem);
  21. // Add some other items
  22. for (int i = 0; i < 10; i++) {
  23. combobox.addItem("Item " + i);
  24. }
  25. main.addComponent(combobox);
  26. }
  27. }