当前位置: 代码迷 >> Java相关 >> 又通不过了
  详细解决方案

又通不过了

热度:186   发布时间:2007-01-22 13:12:00.0
又通不过了

//使用CustomButton类的AveragingApplet小程序

import java.awt.*;
import java.applet.*;
import java.awt.event.*;

//<applet code=AverageApplet.class width=400 height=300></applet>

public class AverageApplet extends Applet implements ActionListener
{
public CustomAverage average;
public TextField input1,input2,display;
public Label labelTitle,label1input,label2input,label3display;

public Color newColor;
public Font newFont;
public CustomButton b1;
public int num1,num2;

public void init()
{
Panel p1;

newColor=new Color(125,0,255);
newFont=new Font("Helvetica",Font.BOLD+Font.ITALIC,18);
b1=new CustomButton("Push for Average",newColor,Color.yellow,newFont);

average=new CustomAverage();
input1=new TextField(12);
input2=new TextField(12);
display=new TextField(12);
input1.setText("0");
input2.setText("0");
display.setText("");
display.setEditable(false);
labelTitle=new Label("Average Calculator");
label1input=new Label("First Number");
label2input=new Label("Second Number");
label3display=new Label("Computed Average");

p1=new Panel(new GridLayout(8,1,10,10));
b1.addActionListener(this);
p1.add(labelTitle);p1.add(label1input);p1.add(input1);
p1.add(label2input);p1.add(input2);
p1.add(b1);p1.add(label3display);p1.add(display);add(p1);
}

public void actionPerformed(ActionEvent e)
{
display.setText(""+average.getAverage(Integer.parseInt(input1.getText()),
Integer.parseInt(input2.getText())));
}
/*
public void actionPerformed(ActionEvent e)
{
int num1,num2;
double avg;

num1=Integer.parseInt(input1.getText());
num2=Integer.parseInt(input2.getText());
avg=average.getAverage(num1,num2);
display.setText(""+avg);
}
*/

}

搜索更多相关的解决方案: average  display  public  import  

----------------解决方案--------------------------------------------------------
找不到符号嘛

编译器不是说了吗?


F:\lbf-netBeans\Test5\src\AverageApplet.java:11: 找不到符号
符号: 类 CustomAverage
位置: 类 AverageApplet
public CustomAverage average;
F:\lbf-netBeans\Test5\src\AverageApplet.java:17: 找不到符号
符号: 类 CustomButton
位置: 类 AverageApplet
public CustomButton b1;
F:\lbf-netBeans\Test5\src\AverageApplet.java:26: 找不到符号
符号: 类 CustomButton
位置: 类 AverageApplet
b1=new CustomButton("Push for Average",newColor,Color.yellow,newFont);
F:\lbf-netBeans\Test5\src\AverageApplet.java:28: 找不到符号
符号: 类 CustomAverage
位置: 类 AverageApplet
average=new CustomAverage();
4 错误
BUILD FAILED (total time: 0 seconds)

----------------解决方案--------------------------------------------------------
以下是引用千里冰封在2007-1-22 13:16:00的发言:
找不到符号嘛

编译器不是说了吗?


F:\lbf-netBeans\Test5\src\AverageApplet.java:11: 找不到符号
符号: 类 CustomAverage//你这个类的定义找不到,在你的程序第11行,以下同理
位置: 类 AverageApplet
public CustomAverage average;
F:\lbf-netBeans\Test5\src\AverageApplet.java:17: 找不到符号
符号: 类 CustomButton//这个类的定义也找不到
位置: 类 AverageApplet
public CustomButton b1;
F:\lbf-netBeans\Test5\src\AverageApplet.java:26: 找不到符号
符号: 类 CustomButton
位置: 类 AverageApplet
b1=new CustomButton("Push for Average",newColor,Color.yellow,newFont);
F:\lbf-netBeans\Test5\src\AverageApplet.java:28: 找不到符号
符号: 类 CustomAverage
位置: 类 AverageApplet
average=new CustomAverage();
4 错误
BUILD FAILED (total time: 0 seconds)


----------------解决方案--------------------------------------------------------
要学会看编译器,他会诉你一切的

----------------解决方案--------------------------------------------------------
别把千里若火了.注意点.呵呵.
----------------解决方案--------------------------------------------------------

----------------解决方案--------------------------------------------------------

知道了,谢谢!


----------------解决方案--------------------------------------------------------
  相关解决方案