0

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() {
    }
}
blalasaadri
  • 5,990
  • 5
  • 38
  • 58
Austin Farris
  • 87
  • 1
  • 2
  • 9

1 Answers1

2

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.

blalasaadri
  • 5,990
  • 5
  • 38
  • 58
  • 2
    +1 Right answer. Also woth to note that in the first versions in which it was available, `@Override` only could be applied to methods overriden from the superclass. In Java 7, you can also apply `@Override` to methods implemented from an interface. – SJuan76 Nov 12 '14 at 00:18
  • the main reason i had used @Override was because it stated it here https://pivot.apache.org/tutorials/helloworld.html I'm trying to teach myself from this website – Austin Farris Nov 12 '14 at 00:26
  • ok i removed the @Overrides and fixed a few remaining errors and as soon as i went to run the program it would not let me. here is a photo of the issue http://imgur.com/19Fl0XZ – Austin Farris Nov 12 '14 at 01:06
  • 1
    If you look at the tutorial at http://pivot.apache.org/tutorials/hello-world.html you will find the following line: `public class HelloJava implements Application {`. So, you should also implement `Application` and have the `@Override` annotations. Removing them is not a good idea; these annotations are markers saying *"There is a function that I **want** to override, please show an error if I don't."* – blalasaadri Nov 12 '14 at 09:17
  • I'm and idiot, thank you for pointing that out. Works great now thank you – Austin Farris Nov 13 '14 at 00:46