0

使用 GXT 和 Java 尝试学习。只是通过 eclipse 测试它会让我进入一个没有按钮的空白页面,我使用了 sencha 的按钮示例,它显示在那里,然后当我采取到目前为止我学到的必要的东西时,我仍然无法生成单个文本按钮。

package com.custom.test.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.sencha.gxt.cell.core.client.ButtonCell.ButtonScale;
import com.sencha.gxt.core.client.resources.ThemeStyles;
import com.sencha.gxt.widget.core.client.ContentPanel;
import com.sencha.gxt.widget.core.client.ContentPanel.ContentPanelAppearance;
import com.sencha.gxt.widget.core.client.FramedPanel.FramedPanelAppearance;
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
import com.sencha.gxt.widget.core.client.button.CellButtonBase;

/**
 *  Entry point classes define <code>onModuleLoad()</code>.
 */
public class Test implements EntryPoint {
    @Override
    public void onModuleLoad() {
        VerticalPanel vp = new VerticalPanel();
        ContentPanel cp = new ContentPanel();
        vp.setSpacing(10);
        vp.setWidth("400px");
        HorizontalPanel hp = new HorizontalPanel();
        hp.setSpacing(5);
        Buttons b = new Buttons();
        CellButtonBase<?> small = b.createButton(Buttons.Category.NORMAL, Buttons.Type.TEXT);
        b.configureButton(small, Buttons.Type.TEXT, ButtonScale.SMALL);
        hp.add(small);
        vp.add(hp);
        cp = new ContentPanel(GWT.<ContentPanelAppearance> create(FramedPanelAppearance.class));
        cp.addStyleName("margin-10");
        cp.setPixelSize(500, 400);
        cp.getBody().getStyle().setBackgroundColor("white");
        cp.getBody().addClassName(ThemeStyles.getStyle().border());
        cp.add(vp);
        cp.show();
    }
}
4

1 回答 1

0

不确定这是否需要,但试试这个

 cp.add(b);

? 也许 ?

编辑:

package com.custom.test.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.sencha.gxt.cell.core.client.ButtonCell.ButtonScale;
import com.sencha.gxt.core.client.resources.ThemeStyles;
import com.sencha.gxt.widget.core.client.ContentPanel;
import com.sencha.gxt.widget.core.client.ContentPanel.ContentPanelAppearance;
import com.sencha.gxt.widget.core.client.FramedPanel.FramedPanelAppearance;
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
import com.sencha.gxt.widget.core.client.button.CellButtonBase;

/**
 *  Entry point classes define <code>onModuleLoad()</code>.
 */
public class Test implements EntryPoint {
    @Override
    public void onModuleLoad() {
        VerticalPanel vp = new VerticalPanel();
        ContentPanel cp = new ContentPanel();
        vp.setSpacing(10);
        vp.setWidth("400px");
        HorizontalPanel hp = new HorizontalPanel();
        hp.setSpacing(5);
        Buttons b = new Buttons();
        CellButtonBase<?> small = b.createButton(Buttons.Category.NORMAL, Buttons.Type.TEXT);
        b.configureButton(small, Buttons.Type.TEXT, ButtonScale.SMALL);
        hp.add(small);
        vp.add(hp);
        vp.add(b); //you are adding everything except the actual button
        cp = new ContentPanel(GWT.<ContentPanelAppearance> create(FramedPanelAppearance.class));
        cp.addStyleName("margin-10");
        cp.setPixelSize(500, 400);
        cp.getBody().getStyle().setBackgroundColor("white");
        cp.getBody().addClassName(ThemeStyles.getStyle().border());
        cp.add(vp);
        cp.show();
    }
}
于 2013-01-03T04:49:03.927 回答