0
我一直得到這個錯誤,我似乎無法弄清楚爲什麼有什麼想法?(不會編譯) 這是一個從我的工作控制檯應用程序(教育原因)。 感謝球員...獲取錯誤:BodyMassApplet不是抽象的,並且不覆蓋抽象方法actionPerformed(ActionEvent)
錯誤:BodyMassApplet不是抽象的,的actionPerformed(ActionEvent事件)中的ActionListener 公共類BodyMassApplet擴展小程序實現的ActionListener
代碼不覆蓋抽象方法:
/*
Name : ****************
Date : 13/02/14
Reason : Bodymass calculator
Chapter : 3
Programs Name : BodyMassApplet.java
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class BodyMassApplet extends Applet implements ActionListener
{
//declare vars
Image logo;//declare an image object
int inches, pounds;
double meters, kilograms, index;
//construct components
Label companyLabel = new Label ("THE SUN FITNESS CENTER BODY MASS INDEX CALCULATOR");
Label heightLabel = new Label("Enter your height to the nearest inch : ");
TextField heightFeild = new TextField (10);
Label weightLabel = new Label ("Enter your weight to the nearest pound : ");
TextField weightFeild = new TextField (10);
Button calcButton = new Button ("Calculate");
Label outputLabel = new Label ("Click the Calculate button to see your Body Mass Index. ");
public void init()
{
setForeground(Color.red);
add(companyLabel);
add(heightLabel);
add(heightFeild);
add(weightLabel);
add(weightFeild);
add(calcButton);
calcButton.addActionListener(this);
add(outputLabel);
logo = getImage(getDocumentBase(),"log.gif");
}//Close init method
public void actionPerfomed(ActionEvent e)
{
inches = Integer.parseInt(heightFeild.getText());
pounds = Integer.parseInt(weightFeild.getText());
meters = inches /39.36;
kilograms =pounds /2.2;
index = kilograms/Math.pow(meters,2);
outputLabel.setText("Your Body Mass Index Is" + Math.round(index)+ ".");
}
public void paint(Graphics g)
{
g.drawImage(logo,125,160,this);
}
}//close applet class
不要回答那些在程序員中脫離主題的問題。不要創造更多混亂。標記爲off-topic和建議(在評論中)OP在Stack Overflow處詢問,就像gnat所做的那樣。 – trejder
謝謝你們,我在問這個問題後幾分鐘就發現它,但沒有足夠的觀點來回答我自己的問題......是的,我知道日食,雖然我在做軟件的過程中有軟件,但我們必須使用它的介紹到Java課程,所以我不得不使用基本編輯器不能使用IDE ....可能聽起來很奇怪,但它是如何關閉這個主題這是Java交流? – Reign