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.

ColorPickerApplication.java 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package com.itmill.toolkit.demo.colorpicker;
  2. import com.itmill.toolkit.data.Property.ValueChangeEvent;
  3. import com.itmill.toolkit.data.Property.ValueChangeListener;
  4. import com.itmill.toolkit.ui.*;
  5. import com.itmill.toolkit.ui.Button.ClickEvent;
  6. /**
  7. * Demonstration application that shows how to use a simple custom client-side
  8. * GWT component, the ColorPicker.
  9. */
  10. public class ColorPickerApplication extends com.itmill.toolkit.Application {
  11. Window main = new Window("Color Picker Demo");
  12. /* The custom component. */
  13. ColorPicker colorselector = new ColorPicker();
  14. /* Another component. */
  15. Label colorname;
  16. public void init() {
  17. setMainWindow(main);
  18. setTheme("demo");
  19. // Listen for value change events in the custom component,
  20. // triggered when user clicks a button to select another color.
  21. colorselector.addListener(new ValueChangeListener() {
  22. public void valueChange(ValueChangeEvent event) {
  23. // Provide some server-side feedback
  24. colorname.setValue("Selected color: "
  25. + colorselector.getColor());
  26. }
  27. });
  28. main.addComponent(colorselector);
  29. // Add another component to give feedback from server-side code
  30. colorname = new Label("Selected color: " + colorselector.getColor());
  31. main.addComponent(colorname);
  32. // Server-side manipulation of the component state
  33. Button button = new Button("Set to white");
  34. button.addListener(new Button.ClickListener() {
  35. public void buttonClick(ClickEvent event) {
  36. colorselector.setColor("white");
  37. }
  38. });
  39. main.addComponent(button);
  40. }
  41. }