[英]@Override Issues with Apache pivot
I am just getting into implementing Apache Pivot into my programing and I am having issues with @Override
. 我只是要在编程中实现Apache Pivot,而@Override
遇到了问题。 I get an error code in variation of this: 在此变化中,我得到一个错误代码:
"The method shutdown(boolean) of type Chief must override or implement a supertype method" “类型为Chief的方法shutdown(boolean)必须重写或实现超类型方法”
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
. 我用//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() {
}
}
The @Override
annotation only makes sense when you're extending a class or implementing an interface. @Override
注释仅在扩展类或实现接口时才有意义。 You're doing neither here. 您在这里都不做。
My guess is that you're trying to extend Application.Adapter
which is documented here . 我的猜测是您正在尝试扩展Application.Adapter
, 在此进行了说明 。 If so, replace 如果是这样,请更换
public class Chief { //...
with 与
public class Chief extends Adapter { //...
while importing org.apache.pivot.wtk.Application.Adapter
. 在导入org.apache.pivot.wtk.Application.Adapter
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.