01: /*
02: * GWT-Ext Widget Library
03: * Copyright(c) 2007-2008, GWT-Ext.
04: * licensing@gwt-ext.com
05: *
06: * http://www.gwt-ext.com/license
07: */
08: package com.gwtext.sample.showcase2.client.misc;
09:
10: import com.gwtext.client.widgets.ColorPalette;
11: import com.gwtext.client.widgets.Panel;
12: import com.gwtext.client.widgets.event.ColorPaletteListenerAdapter;
13: import com.gwtext.client.widgets.form.TextField;
14: import com.gwtext.sample.showcase2.client.ShowcasePanel;
15: import com.google.gwt.user.client.ui.VerticalPanel;
16:
17: public class ColorPaletteSample extends ShowcasePanel {
18:
19: public String getSourceUrl() {
20: return "source/misc/ColorPaletteSample.java.html";
21: }
22:
23: public Panel getViewPanel() {
24: if (panel == null) {
25: panel = new Panel();
26:
27: VerticalPanel verticalPanel = new VerticalPanel();
28: verticalPanel.setSpacing(15);
29:
30: final TextField textField = new TextField("Color");
31: textField.setWidth(146);
32:
33: ColorPalette colorPalette = new ColorPalette();
34: colorPalette.addListener(new ColorPaletteListenerAdapter() {
35: public void onSelect(ColorPalette colorPalette,
36: String color) {
37: textField.setStyle("background-color:" + color
38: + ";background-image:none;");
39: textField.setValue(color);
40: }
41: });
42:
43: colorPalette.setTitle("Pick a color");
44: verticalPanel.add(colorPalette);
45: verticalPanel.add(textField);
46:
47: panel.add(verticalPanel);
48: }
49: return panel;
50: }
51:
52: public String getIntro() {
53: return "A customizable ColorPalette that allows you to define the set of colors displayed. You can also attach listeners to determine the color selected by the user.";
54: }
55: }
|