java - 在 GWT 中导入枚举

标签 java gwt enums import

我有以下代码。

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.UIObject;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.LayoutPanel;
import com.google.gwt.user.client.ui.RootLayoutPanel;
import com.google.gwt.user.client.ui.Widget;

public class LayoutPanelExample implements EntryPoint{
    @Override
     public void onModuleLoad() {
         Widget childone = new HTML("left"),childtwo=new HTML("right");
         LayoutPanel p = new LayoutPanel();
         p.add(childone);
         p.add(childtwo);
         p.setWidgetLeftWidth(childone, 0, PCT, 50, PCT);
         p.setWidgetRightWidth(childtwo, 0, PCT, 50, PCT);
         RootLayoutPanel rp = RootLayoutPanel.get();
         rp.add(p);
     }
}

但它向我显示了这个错误:

C:\XAMPP\xampp\htdocs\LayoutPanelExample\src\java\LayoutPanelExample.java:19: cannot find symbol
symbol  : variable PCT
location: class LayoutPanelExample
     p.setWidgetLeftWidth(childone, 0, PCT, 50, PCT);

但是我在网上看到可以这样申报PCT。我应该导入一些附加 header 还是做什么?

最佳答案

您忘记导入 PCT。

import static com.google.gwt.dom.client.Style.Unit.PCT;

关于java - 在 GWT 中导入枚举,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3618678/

相关文章:

java - 使用二元运算查明 int 是否包含枚举集中的元素

ruby-on-rails - ActiveRecord::Enum - PG::InvalidTextRepresentation:错误:整数输入语法无效:

java - 带有引导 : "There was an unexpected error (type=Not Found, status=404)" 的 Spring MVC

java - 同名JAVA类中的静态和非静态方法

java - 在大型应用程序中处理事务管理

Eclipse Tomcat 资源可用列表不包含 Gwt 2.7.0 maven 应用程序

java - 从另一个特定类访问类方法

javascript - 在javascript中设置浏览器窗口的默认时区

java - 422 ReSTLet ClientProxy 和 GAE 服务器上无法处理的实体

c# - 是否可以在 GraphQL 中发送具有多个值的 Enum