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.button;
09:
10: import com.gwtext.client.widgets.CycleButton;
11: import com.gwtext.client.widgets.Panel;
12: import com.gwtext.client.widgets.event.CycleButtonListenerAdapter;
13: import com.gwtext.client.widgets.menu.CheckItem;
14: import com.gwtext.sample.showcase2.client.ShowcasePanel;
15:
16: /**
17: * Cycle Button example.
18: */
19: public class CycleButtonSample extends ShowcasePanel {
20:
21: public String getSourceUrl() {
22: return "source/button/CycleButtonSample.java.html";
23: }
24:
25: public Panel getViewPanel() {
26: if (panel == null) {
27: panel = new Panel();
28:
29: //create a CycleButton
30: CycleButton button = new CycleButton();
31: button.setShowText(true);
32: button.setPrependText("View as ");
33:
34: //add CheckItem's to the CycleButton
35: button.addItem(new CheckItem("text only", true));
36: button.addItem(new CheckItem("HTML", false));
37:
38: //log check item changes
39: button.addListener(new CycleButtonListenerAdapter() {
40: public void onChange(CycleButton self, CheckItem item) {
41: log(EVENT, item.getText() + " selected.");
42: }
43: });
44:
45: panel.add(button);
46: }
47: return panel;
48: }
49:
50: protected boolean showEvents() {
51: return true;
52: }
53:
54: public String getIntro() {
55: return "<p>A CycleButton is specialized SplitButton that contains Menu CheckItem elements.</p><p>The button automatically "
56: + "cycles through each menu item on click, raising the button's change event for the active menu item. "
57: + "Clicking on the arrow section of the button displays the dropdown menu just like a normal SplitButton.</p>";
58: }
59: }
|