关闭

GXT

3051人阅读 评论(0) 收藏 举报

使用的是google的插件.
最新的eclipse 3.5
gwt 版本是 1.7.

花了一天时间写点demo 看看这些组件都怎么使用的..

 

1

GWT1.7版本下面是不推荐使用Listener了.而改用Handler了.

似乎这样每一个button都可以添加子节点handler了.

然后在上面编写代码.

 

2

在内部类里面要调用父类的属性的时候.要添加fianl字段.

但是这并不是说这个类不可修改.这类的属性可以修改.

 

3.要是保存临时数据.

可以通过创建数组的方式去实现.

比如 final  int[]  userNo = { 0 };

 然后在内部类里面

 

testRPCButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                userNo[0] = 1;
                });
            }
        });

通过这样的方式进行赋值.

 

4,都换成handler.

然后在这里面对其他Wiget进行操作.(这些wiget必须都是final的.)

 

5,在client里面是不可以用java.util.Random()的.

 

作为替换的使用:

com.google.gwt.user.client.Random

Random.nextInt() 下面的静态方法取得.

 

6,面板是没有addHandler的方法的.

 

7.在rcp当中要做的:

1) 创建借口并(在client包下)添加@RemoteServiceRelativePath("testRPC")

testRPC是定义的url.

2)借口必须.extends RemoteService

3)创建interface TestRPCAsync 回调接口.

4)实现接口.(在servic包下.)

5)在web.xml里面添加servlet(很重要否则报错:

 

2009-9-7 8:18:18 com.google.appengine.tools.development.LocalResourceFileServlet doGet
WARNING: No file found for: /test002/testRPC

 

 <!-- Servlets -->
  <servlet>
    <servlet-name>testRPC</servlet-name>
    <servlet-class>com.demo.test.server.TestRPCImpl</servlet-class>
  </servlet>
 
  <servlet-mapping>
    <servlet-name>testRPC</servlet-name>
    <url-pattern>/test002/testRPC</url-pattern>
  </servlet-mapping>

6)gwt中声明接口.

private final TestRPCAsync testRPCAsync = GWT.create(TestRPC.class);

7)在onclick中使用.

 

testRPCButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                System.out.println("here call function.");
                testRPCAsync.getString(new AsyncCallback<String>() {
                    public void onSuccess(String result) {
                        System.out.println(result);
                        Window.alert(result);
                    }
                    public void onFailure(Throwable caught) {
                       
                    }
                });
            }
        });

详细参考附件代码.

 

 



 


 


 

 

 

 

Java代码  收藏代码
  1. public class Test002 implements EntryPoint {  
  2.   
  3.     /** 
  4.      * This is the entry point method. 
  5.      */  
  6.     public void onModuleLoad() {  
  7.   
  8.         System.out.println("系统加载的时候显示....");  
  9.         // /butotn测试开始.  
  10.         final Button button_1 = new Button("测试按钮.");  
  11.         button_1.addClickHandler(new ClickHandler() {  
  12.             public void onClick(ClickEvent event) {  
  13.                 System.out.println("get here.***");  
  14.                 Window.alert("test");  
  15.   
  16.             }  
  17.         });  
  18.         button_1.addKeyDownHandler(new KeyDownHandler() {  
  19.   
  20.             public void onKeyDown(KeyDownEvent event) {  
  21.                 System.out.println("添加事件.");  
  22.                 System.out.println(event.toString());  
  23.             }  
  24.         });  
  25.         // /butotn测试结束.  
  26.         RootPanel.get().add(new HTML("<br>Button测试"));  
  27.         RootPanel.get().add(button_1);  
  28.   
  29.         final CheckBox checkBox1 = new CheckBox("checkBox1.");  
  30.         final CheckBox checkBox2 = new CheckBox("checkBox2.");  
  31.         checkBox1.addClickHandler(new ClickHandler() {  
  32.             public void onClick(ClickEvent event) {  
  33.                 // TODO Auto-generated method stub  
  34.                 System.out.println("点击了checkbox1.");  
  35.                 if (checkBox1.getValue()) {  
  36.                     checkBox2.setValue(false);  
  37.                 } else {  
  38.                     checkBox2.setValue(true);  
  39.                 }  
  40.                 // Window.alert("check it .");  
  41.             }  
  42.         });  
  43.         checkBox2.addClickHandler(new ClickHandler() {  
  44.             public void onClick(ClickEvent event) {  
  45.                 // TODO Auto-generated method stub  
  46.                 System.out.println("点击了checkbox2.");  
  47.                 if (checkBox2.getValue()) {  
  48.                     checkBox1.setValue(false);  
  49.                 } else {  
  50.                     checkBox1.setValue(true);  
  51.                 }  
  52.                 // Window.alert("check it .");  
  53.             }  
  54.         });  
  55.   
  56.         RootPanel.get().add(new HTML("<br>checkBox测试."));  
  57.         RootPanel.get().add(checkBox1);  
  58.         RootPanel.get().add(checkBox2);  
  59.   
  60.         // checkbox测试结束.  
  61.   
  62.         final RadioButton radio1 = new RadioButton("class""obj_1");  
  63.         final RadioButton radio2 = new RadioButton("class""obj_2");  
  64.         final RadioButton radio3 = new RadioButton("class""obj_3");  
  65.   
  66.         RootPanel.get().add(new HTML("<br>RadioButton测试."));  
  67.         RootPanel.get().add(radio1);  
  68.         RootPanel.get().add(radio2);  
  69.         RootPanel.get().add(radio3);  
  70.         // Radio测试.将radio进行多个选择.  
  71.   
  72.         final TextBox textBox = new TextBox();  
  73.         textBox.setTextAlignment(TextBoxBase.ALIGN_RIGHT);  
  74.         // 设置里面的文本内容成右对齐.  
  75.         final Label label_1 = new Label();  
  76.         textBox.addKeyUpHandler(new KeyUpHandler() {  
  77.   
  78.             public void onKeyUp(KeyUpEvent event) {  
  79.                 // 说明.用changeListener的时候.在光标未移出的时候不会改变.  
  80.                 // TODO Auto-generated method stub  
  81.                 String temp = textBox.getText();  
  82.                 System.out.println(temp);  
  83.                 // System.out.println(event.getNativeKeyCode());  
  84.                 label_1.setText(temp);  
  85.             }  
  86.         });  
  87.         // KeyboardListenerAdapter  
  88.         RootPanel.get().add(new HTML("<br>TextBox测试."));  
  89.         RootPanel.get().add(textBox);  
  90.         RootPanel.get().add(new HTML("您输入的参数."));  
  91.         RootPanel.get().add(label_1);  
  92.         // TextBox测试结束.  
  93.   
  94.         final ListBox listBox1 = new ListBox();  
  95.         listBox1.setVisibleItemCount(6);// 设置成可选数目是6.  
  96.         listBox1.addItem("001");  
  97.         listBox1.addItem("002");  
  98.         listBox1.addItem("003");  
  99.         listBox1.addItem("004");  
  100.         final ListBox listBox2 = new ListBox();  
  101.         listBox2.setVisibleItemCount(6);  
  102.         ;// 设置成可选数目是6.  
  103.         listBox1.addClickHandler(new ClickHandler() {  
  104.             public void onClick(ClickEvent event) {  
  105.                 int id = listBox1.getSelectedIndex();  
  106.                 listBox2.clear();// 清除所有选项.  
  107.                 for (int i = 0; i < 4; i++) {  
  108.                     listBox2.addItem(id + "city:\t" + i);  
  109.                 }  
  110.             }  
  111.         });  
  112.   
  113.         RootPanel.get().add(new HTML("<br>ListBox测试."));  
  114.         RootPanel.get().add(listBox1);  
  115.         RootPanel.get().add(listBox2);  
  116.         // ListBox结束.  
  117.   
  118.         Frame frame = new Frame();  
  119.         frame.setUrl("http://ww.google.com");  
  120.         RootPanel.get().add(new HTML("<BR>Frame测试."));  
  121.         RootPanel.get().add(frame);  
  122.         // Frame测试结束.  
  123.   
  124.         PushButton pushButton = new PushButton("PushButton");  
  125.         pushButton.setWidth("180px");  
  126.         RootPanel.get().add(new HTML("<BR>PushButton测试."));  
  127.         RootPanel.get().add(pushButton);  
  128.         // 相似的是togglebutton.PushButton测试结束.  
  129.   
  130.         RichTextArea area = new RichTextArea();  
  131.         area.setHTML("<font color='red'>abc</font>");  
  132.         // area.BasicFormatter.setBackColor("blue");  
  133.         RootPanel.get().add(new HTML("<BR>RichTextArea测试."));  
  134.         RootPanel.get().add(area);  
  135.         // 富文本编辑器设置BasicFormatter还不会使用.//结束.  
  136.   
  137.         MenuBar menuBarMain = new MenuBar();  
  138.         Command cmd = new Command() {  
  139.             public void execute() {  
  140.                 Window.alert("点击Menu.");  
  141.             }  
  142.         };  
  143.         MenuBar bar01 = new MenuBar(true);  
  144.         // 设置true的时候.显示竖向菜单.  
  145.         bar01.addItem("001", cmd);  
  146.         bar01.addItem("002", cmd);  
  147.         bar01.addItem("003", (new MenuBar(true).addItem("子菜单.", cmd)  
  148.                 .getParentMenu()));  
  149.         // 偷懒的写法.没有去创建一个类.  
  150.   
  151.         // 主菜单显示.  
  152.         menuBarMain.addItem("File", bar01);  
  153.         menuBarMain.addItem("Save", bar01);  
  154.         menuBarMain.addItem("Exit", bar01);  
  155.   
  156.         RootPanel.get().add(new HTML("<BR>MenuBar测试."));  
  157.         RootPanel.get().add(menuBarMain);  
  158.         RootPanel.get().add(new HTML("<BR>"));  
  159.         // 富文本编辑器设置BasicFormatter还不会使用.//结束.  
  160.   
  161.         final TabBar tabBar = new TabBar();  
  162.         final Label tabBarLabel = new Label();  
  163.         final String[] tabBarLabelText = { "这个是第1个TabBar.""这个是第2个TabBar.",  
  164.                 "这个是第3个TabBar.""这个是新添加的第1个TabBar.""这个是新添加的第2个TabBar." };  
  165.         tabBar.addTab("这个是第1个TabBar.");  
  166.         tabBar.addTab("这个是第2个TabBar.");  
  167.         tabBar.addTab("这个是第3个TabBar.");  
  168.         final int[] tabBarAddId = new int[] { -1, -1 };  
  169.         // 设置一个数组变量存储值.这里不可以是一个int型.这样会改变不了值.  
  170.         tabBar.addSelectionHandler(new SelectionHandler<Integer>() {  
  171.             public void onSelection(SelectionEvent<Integer> event) {  
  172.                 System.out.println(tabBar.getSelectedTab());  
  173.                 tabBarLabel.setText(tabBarLabelText[tabBar.getSelectedTab()]);  
  174.             }  
  175.         });  
  176.         final Button button_tab_1 = new Button("TabBar切换1.");  
  177.         final Button button_tab_2 = new Button("TabBar切换2.");  
  178.         button_tab_1.addClickHandler(new ClickHandler() {  
  179.             public void onClick(ClickEvent event) {  
  180.                 if (tabBarAddId[0] != -1) {  
  181.                     tabBar.selectTab(tabBarAddId[0]);  
  182.                     tabBarLabel  
  183.                             .setText(tabBarLabelText[tabBar.getSelectedTab()]);  
  184.                 } else {  
  185.                     tabBarAddId[0] = tabBar.getTabCount();  
  186.                     tabBar.insertTab("TabBar切换1.", tabBar.getTabCount());  
  187.   
  188.                     tabBar.selectTab(tabBarAddId[0]);  
  189.                     tabBarLabel  
  190.                             .setText(tabBarLabelText[tabBar.getSelectedTab()]);  
  191.                 }  
  192.             }  
  193.         });  
  194.         button_tab_2.addClickHandler(new ClickHandler() {  
  195.             public void onClick(ClickEvent event) {  
  196.                 if (tabBarAddId[1] != -1) {  
  197.                     tabBar.selectTab(tabBarAddId[1]);  
  198.                     tabBarLabel  
  199.                             .setText(tabBarLabelText[tabBar.getSelectedTab()]);  
  200.                 } else {  
  201.                     tabBarAddId[1] = tabBar.getTabCount();  
  202.                     tabBar.insertTab("TabBar切换2.", tabBar.getTabCount());  
  203.   
  204.                     tabBar.selectTab(tabBarAddId[1]);  
  205.                     tabBarLabel  
  206.                             .setText(tabBarLabelText[tabBar.getSelectedTab()]);  
  207.                 }  
  208.             }  
  209.         });  
  210.         RootPanel.get().add(new HTML("<BR>MenuBar测试."));  
  211.         RootPanel.get().add(tabBar);  
  212.         RootPanel.get().add(tabBarLabel);  
  213.         RootPanel.get().add(button_tab_1);  
  214.         RootPanel.get().add(button_tab_2);  
  215.   
  216.         // 设置一个数组变量存储值.这里不可以是一个int型.这样会改变不了值.  
  217.   
  218.         final Grid grid = new Grid(33);  
  219.         // 设置网格的数量.3X3的网格.  
  220.         grid.setBorderWidth(2);  
  221.         // 设置边线的宽度是2.  
  222.         grid.setWidth("100%");  
  223.         // 设置显示宽是100%.  
  224.         grid.setWidget(00new HTML("hello!"));  
  225.         grid.setWidget(11new HTML("hello!"));  
  226.         grid.setWidget(22new HTML("hello!"));  
  227.         grid.setWidget(12new HTML("hello!"));  
  228.         // 插入测试数据.数据是从(0,0)开始到(2,2)结束.  
  229.         RootPanel.get().add(new HTML("<BR>Grid测试."));  
  230.         RootPanel.get().add(grid);  
  231.         grid.addClickHandler(new ClickHandler() {  
  232.             public void onClick(ClickEvent event) {  
  233.                 // TODO Auto-generated method stub  
  234.                 System.out.print("点击了:["  
  235.                         + grid.getCellForEvent(event).getRowIndex());  
  236.                 // 获得行.  
  237.                 System.out.println(","  
  238.                         + grid.getCellForEvent(event).getCellIndex() + "]");  
  239.                 // 获得列.  
  240.             }  
  241.         });  
  242.         // Grid测试结束.  
  243.   
  244.         final FlexTable flexTable = new FlexTable();  
  245.         // 和grid的区别是不用设置大小.  
  246.         flexTable.setWidth("100%");  
  247.         flexTable.setBorderWidth(1);  
  248.         flexTable.setCellPadding(1);  
  249.         flexTable.setCellSpacing(1);  
  250.         // 设置边框.  
  251.         for (int i = 0; i < 16; i++) {  
  252.             flexTable.setText(i / 4, i % 4"id:" + i);  
  253.         }  
  254.         flexTable.addClickHandler(new ClickHandler() {  
  255.             public void onClick(ClickEvent event) {  
  256.                 System.out.print("点击了:["  
  257.                         + flexTable.getCellForEvent(event).getRowIndex());  
  258.                 // 获得行.  
  259.                 System.out  
  260.                         .println(","  
  261.                                 + flexTable.getCellForEvent(event)  
  262.                                         .getCellIndex() + "]");  
  263.                 // 获得列.  
  264.             }  
  265.         });  
  266.         RootPanel.get().add(new HTML("<BR>FlexTable测试."));  
  267.         RootPanel.get().add(flexTable);  
  268.         // FlexTable测试结束.  
  269.   
  270.         RootPanel.get().add(new HTML("<BR>HTMLTable测试."));  
  271.         // RootPanel.get().add();  
  272.         // htmlTable测试结束.  
  273.   
  274.         final Tree tree = new Tree();  
  275.         TreeItem treeItem1 = new TreeItem("01");  
  276.         treeItem1.addItem(new TreeItem("sub01"));  
  277.         TreeItem treeItem2 = new TreeItem("02");  
  278.         treeItem2.addItem(new TreeItem("sub02"));  
  279.   
  280.         TreeItem treeItem3 = new TreeItem("03");  
  281.         TreeItem treeItem3_1 = new TreeItem("03_1");  
  282.         treeItem3.addItem(treeItem3_1);  
  283.         TreeItem treeItem3_2 = new TreeItem("03_2");  
  284.         treeItem3_1.addItem(treeItem3_2);  
  285.         TreeItem treeItem3_3 = new TreeItem("03_3");  
  286.         treeItem3_2.addItem(treeItem3_3);  
  287.   
  288.         tree.addItem(treeItem1);  
  289.         tree.addItem(treeItem2);  
  290.         tree.addItem(treeItem3);  
  291.         tree.addOpenHandler(new OpenHandler<TreeItem>() {  
  292.             public void onOpen(OpenEvent<TreeItem> event) {  
  293.                 System.out.println("tree onOpen:\t" + event.getTarget().getHTML());  
  294.             }  
  295.         });  
  296.         tree.addCloseHandler(new CloseHandler<TreeItem>() {  
  297.             public void onClose(CloseEvent<TreeItem> event) {  
  298.                 System.out.println("tree onClose:\t" + event.getTarget().getHTML());  
  299.             }  
  300.         });  
  301.         tree.addSelectionHandler(new SelectionHandler<TreeItem>() {  
  302.             public void onSelection(SelectionEvent<TreeItem> event) {   
  303.                 // TODO Auto-generated method stub  
  304.                 System.out.println("tree onSelection:\t" + tree.getSelectedItem().getHTML());  
  305.             }  
  306.         });  
  307.         RootPanel.get().add(new HTML("<BR>Tree测试."));  
  308.         RootPanel.get().add(tree);  
  309.         // Tree测试结束.  
  310.           
  311.         Image image = new Image();  
  312.         image.setUrl("ui-icons.png");  
  313.         image.setVisibleRect(01921616);  
  314.         final PushButton button_image = new PushButton(image);  
  315.         button_image.setWidth("16px");  
  316.         button_image.setHeight("16px");  
  317.         button_image.addClickHandler(new ClickHandler() {  
  318.             public void onClick(ClickEvent event) {  
  319.                 Window.alert("imageButon");  
  320.             }  
  321.         });  
  322.         RootPanel.get().add(new HTML("<BR>Image测试."));  
  323.         RootPanel.get().add(new Image("ui-icons.png",01921616));  
  324.         //直接将图片参数设置.//这里的image被button用了.显示不了.  
  325.         //要重新定义一个button才可以显示.  
  326.         RootPanel.get().add(new HTML("<BR>Image测试."));  
  327.         RootPanel.get().add(button_image);  
  328.         // Image测试结束.  
  329.           
  330.         RootPanel.get().add(new HTML("<BR>#######################布局UI######################."));  
  331.         ScrollPanel scrollPanel = new ScrollPanel();  
  332.         String strText = "";  
  333.         for(int i = 0;i < 100; i ++){  
  334.             strText +="ABCDEFGHI";  
  335.         }  
  336.         scrollPanel.setSize("100px""100px");  
  337.         scrollPanel.setWidget(new HTML(strText));  
  338.         scrollPanel.setVisible(true);  
  339.         RootPanel.get().add(new HTML("<BR>Panel测试."));  
  340.         RootPanel.get().add(scrollPanel);  
  341.         // ScrollPanel测试结束.  
  342.           
  343.           
  344.         final Button button_PopupPanel = new Button("PopupPanelButton");  
  345.         button_PopupPanel.addClickHandler(new ClickHandler() {  
  346.             public void onClick(ClickEvent event) {  
  347.                 System.out.println("click");  
  348.                 //新建一个popup.  
  349.                 /**popupPanel.setPopupPositionAndShow(new PopupPanel.PositionCallback() { 
  350.                     public void setPosition(int offsetWidth, int offsetHeight) { 
  351.                         int left = (Window.getClientWidth() -offsetWidth)/3; 
  352.                         int top = (Window.getClientHeight() - offsetHeight) /3; 
  353.                         popupPanel.setPopupPosition(left, top); 
  354.                     } 
  355.                 }); 
  356.                 */  
  357.                 final PopupPanel popupPanel = new PopupPanel();  
  358.                 Button closeButton = new Button("close");  
  359.                 closeButton.addClickHandler(new ClickHandler() {  
  360.                     public void onClick(ClickEvent event) {  
  361.                         popupPanel.hide();  
  362.                     }  
  363.                 });  
  364.                 VerticalPanel verticalPanel = new VerticalPanel();  
  365.                 verticalPanel.add(new HTML("test Popup."));  
  366.                 verticalPanel.add(closeButton);  
  367.                 popupPanel.add(verticalPanel);  
  368.                 popupPanel.center();  
  369.             }  
  370.         });  
  371.         RootPanel.get().add(new HTML("<BR>PopupPanel测试."));  
  372.         RootPanel.get().add(button_PopupPanel);  
  373.         //RootPanel.get().add(popupPanel);  
  374.         // PopupPanel测试结束.  
  375.           
  376.         //  
  377.         final DialogBox dialogBox = new DialogBox(false,true);  
  378.         //false:是否自动隐藏.(单击DialogBox之外的部分.true:是否是模式对话框.  
  379.         dialogBox.setTitle("弹出对话框.");  
  380.         dialogBox.setText("弹出对话框.");  
  381.         VerticalPanel verticalPanelDialog = new VerticalPanel();  
  382.         verticalPanelDialog.add(new HTML("测试对话框."));  
  383.         Button button_dialog = new Button("确定.");  
  384.         button_dialog.addClickHandler(new ClickHandler() {  
  385.             public void onClick(ClickEvent event) {  
  386.                 dialogBox.hide();  
  387.             }  
  388.         });  
  389.         verticalPanelDialog.add(button_dialog);  
  390.           
  391.         Button button_dialog_show = new Button("显示对话框.");  
  392.         //控制对话框显示.  
  393.         button_dialog_show.addClickHandler(new ClickHandler() {  
  394.             public void onClick(ClickEvent event) {  
  395.                 dialogBox.center();  
  396.                 dialogBox.show();  
  397.             }  
  398.         });  
  399.         dialogBox.add(verticalPanelDialog);  
  400.         //将面板添加到dialog里面  
  401.         RootPanel.get().add(new HTML("<BR>DialogBox测试."));  
  402.         RootPanel.get().add(button_dialog_show);  
  403.         // DialogBox测试结束.  
  404.           
  405.         DockPanel dockPanel = new DockPanel();  
  406.         dockPanel.add(new HTML("NORTH"), DockPanel.NORTH);  
  407.         dockPanel.add(new HTML("SOUTH"), DockPanel.SOUTH);  
  408.         dockPanel.add(new HTML("WEST"), DockPanel.WEST);  
  409.         dockPanel.add(new HTML("EAST"), DockPanel.EAST);  
  410.         dockPanel.add(new HTML("CENTER"), DockPanel.CENTER);  
  411.         dockPanel.setBorderWidth(1);  
  412.         RootPanel.get().add(new HTML("<BR>DockPanel测试."));  
  413.         RootPanel.get().add(dockPanel);  
  414.         // DockPanel测试结束.  
  415.           
  416.         HorizontalPanel horizontalPanel = new HorizontalPanel();  
  417.         horizontalPanel.add(new HTML("test01"));  
  418.         horizontalPanel.add(new HTML("test02"));  
  419.         horizontalPanel.add(new HTML("test03"));  
  420.         horizontalPanel.add(new HTML("test04"));  
  421.         horizontalPanel.setBorderWidth(1);  
  422.         RootPanel.get().add(new HTML("<BR>HorizontalPanel测试."));  
  423.         RootPanel.get().add(horizontalPanel);  
  424.         // HorizontalPanel测试结束.  
  425.           
  426.           
  427.         VerticalPanel verticalPanel = new VerticalPanel();  
  428.         verticalPanel.add(new HTML("test01"));  
  429.         verticalPanel.add(new HTML("test02"));  
  430.         verticalPanel.add(new HTML("test03"));  
  431.         verticalPanel.add(new HTML("test04"));  
  432.         verticalPanel.setBorderWidth(1);  
  433.         RootPanel.get().add(new HTML("<BR>VerticalPanel测试."));  
  434.         RootPanel.get().add(verticalPanel);  
  435.         // VerticalPanel测试结束.  
  436.           
  437.         FlowPanel flowPanel = new FlowPanel();  
  438.         for(int i = 0; i < 20; i ++){  
  439.             flowPanel.add(new HTML("test"+i));  
  440.         }  
  441.         RootPanel.get().add(new HTML("<BR>FlowPanel测试."));  
  442.         ScrollPanel scrollPaneFlow = new ScrollPanel();  
  443.         scrollPaneFlow.add(flowPanel);  
  444.         RootPanel.get().add(scrollPaneFlow);  
  445.         // FlowPanel测试结束.  
  446.           
  447.         StackPanel stackPanel = new StackPanel();  
  448.           
  449.         VerticalPanel verticalPanel_1 = new VerticalPanel();  
  450.         verticalPanel_1.add(new HTML("test01"));  
  451.         verticalPanel_1.add(new HTML("test02"));  
  452.         verticalPanel_1.add(new HTML("test03"));  
  453.         verticalPanel_1.add(new HTML("test04"));  
  454.         stackPanel.add(verticalPanel_1,"verticalPanel_1");  
  455.           
  456.         VerticalPanel verticalPanel_2 = new VerticalPanel();  
  457.         verticalPanel_2.add(new HTML("test01"));  
  458.         verticalPanel_2.add(new HTML("test02"));  
  459.         verticalPanel_2.add(new HTML("test03"));  
  460.         verticalPanel_2.add(new HTML("test04"));  
  461.         stackPanel.add(verticalPanel_2,"verticalPanel_2");  
  462.           
  463.         RootPanel.get().add(new HTML("<BR>StackPanel测试."));  
  464.         RootPanel.get().add(stackPanel);  
  465.         // StackPanel测试结束.  
  466.           
  467.           
  468.         final DeckPanel deckPanel = new DeckPanel();  
  469.         deckPanel.setSize("200px""200px");  
  470.         deckPanel.add(new HTML("<font color='red'>testDeck001</font>"));  
  471.         deckPanel.add(new HTML("<font color='blue'>testDeck002</font>"));  
  472.         deckPanel.add(new HTML("<font color='yellow'>testDeck003</font>"));  
  473.         deckPanel.add(new HTML("<font color='green'>testDeck004</font>"));  
  474.         Button buttonDeck = new Button("test Deck()");  
  475.         final int[] deckNo = {0};  
  476.         buttonDeck.addClickHandler(new ClickHandler() {  
  477.             public void onClick(ClickEvent event) {  
  478.                 //Window.alert(""+deckNo[0]);  
  479.                 deckPanel.showWidget(deckNo[0]);  
  480.                 deckNo[0] = (deckNo[0] + 1) % 4;   
  481.             }  
  482.         });  
  483.         RootPanel.get().add(new HTML("<BR>DeckPanel测试."));  
  484.         RootPanel.get().add(deckPanel);  
  485.         RootPanel.get().add(buttonDeck);  
  486.         //DeckPanel测试结束.  
  487.           
  488.         TabPanel tabPanel = new TabPanel();  
  489.         tabPanel.add(new HTML("TabPanel001Content"), "001");  
  490.         tabPanel.add(new HTML("TabPanel002Content"), "002");  
  491.         tabPanel.add(new HTML("TabPanel003Content"), "003");  
  492.         tabPanel.selectTab(0);  
  493.         RootPanel.get().add(new HTML("<BR>TabPanel测试."));  
  494.         RootPanel.get().add(tabPanel);  
  495.         //TabPanel测试结束.  
  496.           
  497.         DisclosurePanel disclosurePanel = new DisclosurePanel();  
  498.         disclosurePanel.setHeader(new HTML("show"));  
  499.         disclosurePanel.setContent(new HTML("ABCDEFGHIGKLMNOPQRSTUVWXYZ"));  
  500.         RootPanel.get().add(new HTML("<BR>DisclosurePanel测试."));  
  501.         RootPanel.get().add(disclosurePanel);  
  502.         //DisclosurePanel测试结束.  
  503.           
  504.         MultiWordSuggestOracle multiWordSuggestOracle = new MultiWordSuggestOracle();  
  505.         for(int i = 0; i < 100; i ++){  
  506.             //com.google.gwt.user.client.Random静态方法.  
  507.             multiWordSuggestOracle.add(Random.nextInt() + "");  
  508.         }  
  509.         RootPanel.get().add(new HTML("<BR>MultiWordSuggestOracle测试.(测试数字 1 -20)"));  
  510.         SuggestBox suggestBox = new SuggestBox(multiWordSuggestOracle);  
  511.         RootPanel.get().add(suggestBox);  
  512.         //MultiWordSuggestOracle测试结束.  
  513.           
  514.         HorizontalSplitPanel horizontalSplitPanel = new HorizontalSplitPanel();  
  515.         //大小正好是一个屏幕的大小.  
  516.         horizontalSplitPanel.setLeftWidget(new HTML("Left"));  
  517.         horizontalSplitPanel.setRightWidget(new HTML("Right"));  
  518.         RootPanel.get().add(new HTML("<BR>HorizontalSplitPanel测试."));  
  519.         RootPanel.get().add(horizontalSplitPanel);  
  520.         //HorizontalSplitPanel测试结束.  
  521.           
  522.         VerticalSplitPanel verticalSplitPanel = new VerticalSplitPanel();  
  523.         //大小正好是一个屏幕的大小.  
  524.         verticalSplitPanel.setTopWidget(new HTML("Top"));  
  525.         verticalSplitPanel.setBottomWidget(new HTML("Bottom"));  
  526.         RootPanel.get().add(new HTML("<BR>VerticalSplitPanel测试."));  
  527.         RootPanel.get().add(verticalSplitPanel);  
  528.         //VerticalSplitPanel测试结束.  
  529.           
  530.         Button testRPCButton = new Button("testRPC");  
  531.         testRPCButton.addClickHandler(new ClickHandler() {  
  532.             public void onClick(ClickEvent event) {  
  533.                 System.out.println("here call function.");  
  534.                 testRPCAsync.getString(new AsyncCallback<String>() {  
  535.                     public void onSuccess(String result) {  
  536.                         System.out.println(result);  
  537.                         Window.alert(result);  
  538.                     }  
  539.                     public void onFailure(Throwable caught) {  
  540.                           
  541.                     }  
  542.                 });  
  543.             }  
  544.         });  
  545.         RootPanel.get().add(new HTML("<BR>TestRPCAsync测试."));  
  546.         RootPanel.get().add(testRPCButton);  
  547.         //TestRPCAsync测试结束.  
  548.     }  
  549.       
  550.     private final TestRPCAsync testRPCAsync = GWT.create(TestRPC.class);  


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:11102次
    • 积分:198
    • 等级:
    • 排名:千里之外
    • 原创:11篇
    • 转载:6篇
    • 译文:0篇
    • 评论:0条