0

我刚刚开始在我的编程中实现 Apache Pivot,但我遇到了@Override. 我得到一个错误代码:

“Chief 类型的方法 shutdown(boolean) 必须覆盖或实现超类型方法”

这是我的代码非常简单,但无法让它工作。我用 . 标记了发生错误的位置//Error resides here

package portal;

import java.awt.Color;
import java.awt.Font;

import org.apache.pivot.collections.Map;
import org.apache.pivot.wtk.Application;
import org.apache.pivot.wtk.Display;
import org.apache.pivot.wtk.HorizontalAlignment;
import org.apache.pivot.wtk.Label;
import org.apache.pivot.wtk.VerticalAlignment;
import org.apache.pivot.wtk.Window;

public class Chief {
    private Window window = null;

    //Error resides here 
    @Override
    public void startup(Display display, Map<string, String> properties) {
        window = new Window();

        Label label = new Label();
        label.setText("Hello World!");
        label.getStyles().put("font", new Font("Arial", Font.BOLD, 24));
        label.getStyles().put("color", Color.RED);
        label.getStyles().put("horizontalALignment", 
                HorizontalAlighnment.CENTER);
        label.getStyles().put("verticalAlignment",
                VerticalALignment.CENTER);

        window.setContent(label);
        window.setTitle("Hello World!");
        window.setMaximized(true);

        window.open(display);
    }

    //Error resides here  
    @Override
    public boolean shutdown(boolean optional) {
        if (window !=null) {
            window.close();
        } 

        return false;
    }

    //Error resides here    
    @Override
    public void suspend() {
    } 

    //Error resides here
    @Override
    public void resume() {
    }
}
4

1 回答 1

2

只有在扩展类或实现接口时,@Override注释才有意义。你在这里什么都不做。

我的猜测是您正在尝试扩展此处Application.Adapter记录的内容。如果是,请更换

public class Chief { //...

public class Chief extends Adapter { //...

导入时org.apache.pivot.wtk.Application.Adapter

于 2014-11-12T00:15:47.250 回答