Gxt和GWT整合小示例

GXT与GWT集成进行EXT前端编译[原]

这里我用的是GWT2.0和GXT2.1以及EXT3.1。

在gwt项目中public目录下新建目录js/ext,将ext(建议使用3.0以上的版本)发行版解压后的adapter目录、resources目录、ext-all.js文件拷贝到js/ext目录下。

配置gwt.xml:

XML:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<module rename-to="gxt_test">
    <!-- Inherit the core Web Toolkit stuff.                        -->
    <inherits name="com.google.gwt.user.User" />
    <inherits name="com.extjs.gxt.ui.GXT" />

    <!-- Inherit the default GWT style sheet. You can change       -->
    <!-- the theme of your GWT application by uncommenting          -->
    <!-- any one of the following lines.                            -->
    <inherits name="com.google.gwt.user.theme.standard.Standard" />
    <!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
    <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/>     -->

    <!-- Other module inherits                                      -->
    <stylesheet src="js/ext/resources/css/ext-all.css" />
    <script src="js/ext/adapter/ext/ext-base.js" />
    <script src="js/ext/ext-all.js" />
    <!-- Specify the app entry point class.                         -->
    <entry-point class="com.black.app.client.GXT_test" />
    <!-- Specify the paths for translatable code                    -->
    <source path="client" />

</module>

OK,现在进行Java编码,一个简单helloWorld,编译后即可运行。ext帅的要死!

Java:

package com.black.app.client;

import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.TabPanel;
import com.extjs.gxt.ui.client.widget.Window;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.layout.FitData;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;

/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class GXT_test implements EntryPoint {

    /**
     * This is the entry point method.
     */
    public void onModuleLoad() {
        LayoutContainer layout = new LayoutContainer();
        layout.setLayout(new FlowLayout(10));

        final Window window = new Window();
        window.setSize(500, 300);
        window.setPlain(true);
        window.setModal(true);
        window.setBlinkModal(true);
        window.setHeading("Hello Window");
        window.setLayout(new FitLayout());

        TabPanel panel = new TabPanel();
        panel.setBorders(false);
        TabItem item1 = new TabItem("Hello World 1");
        item1.addText("Hello...");
        item1.addStyleName("pad-text");

        TabItem item2 = new TabItem("Hello World 2");
        item2.addText("... World!");
        item2.addStyleName("pad-text");
        panel.add(item1);
        panel.add(item2);

        window.add(panel, new FitData(4));

        window.addButton(new Button("Hello"));
        window.addButton(new Button("World"));

        Button btn = new Button("Hello World",
                new SelectionListener<ButtonEvent>() {
                    @Override
                    public void componentSelected(ButtonEvent ce) {
                        window.show();
                    }
                });
        layout.add(btn);
        RootPanel.get().add(layout);
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值