@Override Issues with Apache pivot

119 Views Asked by At

I am just getting into implementing Apache Pivot into my programing and I am having issues with @Override. I get an error code in variation of this:

"The method shutdown(boolean) of type Chief must override or implement a supertype method"

This is my code very simple but cant manage to get it to work. I marked the locations where the error happens with //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() {
    }
}
1

There are 1 best solutions below

5
blalasaadri On BEST ANSWER

The @Override annotation only makes sense when you're extending a class or implementing an interface. You're doing neither here.

My guess is that you're trying to extend Application.Adapter which is documented here. If so, replace

public class Chief { //...

with

public class Chief extends Adapter { //...

while importing org.apache.pivot.wtk.Application.Adapter.