📄 mainentrypoint.java
字号:
/* * MainEntryPoint.java * * Created on March 4, 2008, 12:24 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */package my.company.client;import com.google.gwt.core.client.EntryPoint;import com.google.gwt.user.client.ui.CheckBox;import com.google.gwt.user.client.ui.ClickListener;import com.google.gwt.user.client.ui.Composite;import com.google.gwt.user.client.ui.RootPanel;import com.google.gwt.user.client.ui.TextBox;import com.google.gwt.user.client.ui.VerticalPanel;import com.google.gwt.user.client.ui.Widget;/** * * @author sang */public class MainEntryPoint implements EntryPoint { /** Creates a new instance of MainEntryPoint */ public MainEntryPoint() { } /** * A composite of a TextBox and a CheckBox that optionally enables it. */ public static class OptionalTextBox extends Composite implements ClickListener { private TextBox textBox = new TextBox(); private CheckBox checkBox = new CheckBox(); /** * Constructs an OptionalTextBox with the given caption on the check. * * @param caption the caption to be displayed with the check box */ public OptionalTextBox(String caption) { // Place the check above the text box using a vertical panel. VerticalPanel panel = new VerticalPanel(); panel.add(checkBox); panel.add(textBox); // Set the check box's caption, and check it by default. checkBox.setText(caption); checkBox.setChecked(true); checkBox.addClickListener(this); // All composites must call initWidget() in their constructors. initWidget(panel); // Give the overall composite a style name. setStyleName("example-OptionalCheckBox"); } public void onClick(Widget sender) { if (sender == checkBox) { // When the check box is clicked, update the text box's enabled state. textBox.setEnabled(checkBox.isChecked()); } } /** * Sets the caption associated with the check box. * * @param caption the check box's caption */ public void setCaption(String caption) { // Note how we use the use composition of the contained widgets to provide // only the methods that we want to. checkBox.setText(caption); } /** * Gets the caption associated with the check box. * * @return the check box's caption */ public String getCaption() { return checkBox.getText(); } } public void onModuleLoad() { // Create an optional text box and add it to the root panel. OptionalTextBox otb = new OptionalTextBox("Check this to enable me"); RootPanel.get().add(otb); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -