我在Eclipse中有这个代码,我想设置每天显示的第一个和最后一个小时。但是,当我输入所谓的代码时,Eclipse会向我显示一个邪恶的小感叹号(在“Calendar cal = ...”下面的out-comment行中)并且不会编译(它说明了关于令牌的语法错误)。我看不出错误......我做错了什么,我该如何解决?
亲切的问候, 卢卡斯
package com.example.evil_wochenplaner_of_death;
import javax.servlet.annotation.WebServlet;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.*;
@SuppressWarnings("serial")
@Theme("evil_wochenplaner_of_death")
public class EwodUI extends UI {
@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = EwodUI.class)
public static class Servlet extends VaadinServlet {
}
Calendar cal = new Calendar ();
//cal.setFirstVisibleHourOfDay (7);
@Override
protected void init(VaadinRequest request) {
HorizontalSplitPanel hspanel = new HorizontalSplitPanel ();
setContent (hspanel);
hspanel.addComponent (cal);
}
}
答案 0 :(得分:1)
您不能在课堂上直接使用cal.setFirstVisibleHourOfDay (7);
这样的语句。
您可以将它移动到init方法,如下所示。
package com.example.evil_wochenplaner_of_death;
import javax.servlet.annotation.WebServlet;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.*;
@SuppressWarnings("serial")
@Theme("evil_wochenplaner_of_death")
public class EwodUI extends UI {
@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = EwodUI.class)
public static class Servlet extends VaadinServlet {
}
Calendar cal = new Calendar ();
//cal.setFirstVisibleHourOfDay (7);
@Override
protected void init(VaadinRequest request) {
HorizontalSplitPanel hspanel = new HorizontalSplitPanel ();
setContent (hspanel);
cal.setFirstVisibleHourOfDay(7);
cal.setLastVisibleHourOfDay (18);
hspanel.addComponent (cal);
}
}