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.core.EventObject;
11: import com.gwtext.client.widgets.Button;
12: import com.gwtext.client.widgets.Panel;
13: import com.gwtext.client.widgets.event.ButtonListenerAdapter;
14: import com.gwtext.client.widgets.layout.HorizontalLayout;
15: import com.gwtext.sample.showcase2.client.ShowcasePanel;
16:
17: /**
18: * Example that illustrates simple buttons.
19: */
20: public class ButtonsSample extends ShowcasePanel {
21:
22: public String getSourceUrl() {
23: return "source/button/ButtonsSample.java.html";
24: }
25:
26: public String getCssUrl() {
27: return "source/button/ButtonsSample.css.html";
28: }
29:
30: public Panel getViewPanel() {
31: if (panel == null) {
32: panel = new Panel();
33:
34: //create a listener for adding an icon to the Button if not present
35: ButtonListenerAdapter listener = new ButtonListenerAdapter() {
36: public void onClick(Button button, EventObject e) {
37: button.setIconCls("c-icon");
38: button.setText("Icon Button");
39: log(EVENT, button.getText() + " clicked");
40: }
41: };
42: Button button = new Button("Set Icon", listener);
43:
44: //icon button
45: Button iconButton = new Button("Search",
46: new ButtonListenerAdapter() {
47: public void onClick(Button button, EventObject e) {
48: log(EVENT, button.getText() + " clicked");
49: }
50: });
51: iconButton.setIconCls("search-icon");
52:
53: //disabled button
54: Button disabled = new Button("Disabled");
55: disabled.setDisabled(true);
56:
57: Panel buttonPanel = new Panel();
58:
59: //layout buttons horizontally with 10 pixels between them
60: buttonPanel.setLayout(new HorizontalLayout(10));
61: buttonPanel.add(button);
62: buttonPanel.add(iconButton);
63: buttonPanel.add(disabled);
64:
65: panel.add(buttonPanel);
66: }
67: return panel;
68: }
69:
70: protected boolean showEvents() {
71: return true;
72: }
73:
74: public String getIntro() {
75: return "<p>This is a simple example illustrating basic Button styles. Notice that when you click the 'Set Icon' button,"
76: + " the button icon gets added dynamically.</p>";
77: }
78: }
|