0

I have this code in Eclipse, where I want to set the first and last hour shown everyday. However, Eclipse is showing me an evil little exclamation mark when I type said code in (the out-commented line right under "Calendar cal = ...") and won't compile (it says something about syntax errors on tokens). I can't see the error... What am I doing wrong and how can I fix this?

Kind Regards, Lukas

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);
    }

}

1 Answers1

1

You cannot have statements like cal.setFirstVisibleHourOfDay (7); directly in class.

You can move it to the init method like shown below.

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);
    }

}
4J41
  • 5,005
  • 1
  • 29
  • 41