编译时不显示按钮(GWT)

时间:2015-06-16 18:34:31

标签: java gwt

我正在Eclipse中编写一个GWT程序,但我没有出现我正在制作的按钮。我不知道为什么。我已经检查了整个程序超过3次。当我编译它时,2个按钮应该出现“Landscape 1”& “风景2”。我没有在clickhandlers中实现任何东西,因为我想让它们首先出现:)这是我的主视图:

package test.client;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.VerticalPanel;

public class MainView extends Composite{
private VerticalPanel vPanel = new VerticalPanel();
private VerticalPanel contentPanel;

public MainView(){
    initWidget(this.vPanel);
    this.vPanel.setBorderWidth(1);

    MenuView menu = new MenuView();
    this.vPanel.add(menu);

    this.contentPanel = new VerticalPanel();
    this.vPanel.add(contentPanel);

}

}

这是我的菜单视图:

package test.client;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HorizontalPanel;

public class MenuView extends Composite {
private HorizontalPanel hPanel = new HorizontalPanel();

public MenuView(){
    initWidget(this.hPanel);

    Button landscape1Btn = new Button("Landscape 1");
    landscape1Btn.addClickHandler(new LS1ClickHandler());
    this.hPanel.add(landscape1Btn);

    Button landscape2Btn = new Button("Landscape 2");
    landscape2Btn.addClickHandler(new LS2ClickHandler());
    this.hPanel.add(landscape2Btn);
}
private class LS1ClickHandler implements ClickHandler{

    @Override
    public void onClick(ClickEvent event) {
        // TODO Auto-generated method stub

    }

}
private class LS2ClickHandler implements ClickHandler{

    @Override
    public void onClick(ClickEvent event) {
        // TODO Auto-generated method stub

    }

}
}

这是主要课程:

package test.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;

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

/**
 * This is the entry point method.
 */
public void onModuleLoad() {
    MainView mainView = new MainView();
    RootPanel.get().add(mainView);
}
}

Html类:

<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">   
<link type="text/css" rel="stylesheet" href="GWT.css">
<title>My first GWT project</title>   
<script type="text/javascript" language="javascript" src="gwt/gwt.nocache.js"></script>
</head>
<body>
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
<noscript>
<div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
</div>
</noscript>
</body>
</html>

0 个答案:

没有答案