import java.awt.*;
import java.awt.event.*;
class Yourwindow extends Frame implements ActionListener
{TextField text1,text2;
PoliceMan police;
Yourwindow()
{ text1=new TextField(10);
text2=new TextField(10);
police=new PoliceMan();
setLayout(new FlowLayout());
add(text1);
add(text2);
text1.addActionListener(this);
text2.addActionListener(police);
setBounds(100,100,150,150);
setVisible(true);
validate();
}
public void actionPerformed(ActionEvent e)
{String number=e.getActionCommand();
int n=Integer.parseInt(number);
int m=n*n;
text2.setText(n+"的平方:"+m);
}
}
class PoliceMan implements ActionListener
{public void actionPerformed(ActionEvent e)
{String number=e.getActionCommand();
int n=Integer.parseInt(number);
int m=n*n*n;
System.out.println(n+"的立方:"+m);
}
}
public class Example1
{ public static void main(String args[])
{ YourWindow win=new YourWindow();
}
}
编译后就2个错误:C:\Documents and Settings\Administrator\My Documents\Example1.java:36: cannot resolve symbol
symbol : class YourWindow
location: class Example1
{ YourWindow win=new YourWindow();
^
C:\Documents and Settings\Administrator\My Documents\Example1.java:36: cannot resolve symbol
symbol : class YourWindow
location: class Example1
{ YourWindow win=new YourWindow();
^
2 errors
import java.awt.event.*;
class Yourwindow extends Frame implements ActionListener
{TextField text1,text2;
PoliceMan police;
Yourwindow()
{ text1=new TextField(10);
text2=new TextField(10);
police=new PoliceMan();
setLayout(new FlowLayout());
add(text1);
add(text2);
text1.addActionListener(this);
text2.addActionListener(police);
setBounds(100,100,150,150);
setVisible(true);
validate();
}
public void actionPerformed(ActionEvent e)
{String number=e.getActionCommand();
int n=Integer.parseInt(number);
int m=n*n;
text2.setText(n+"的平方:"+m);
}
}
class PoliceMan implements ActionListener
{public void actionPerformed(ActionEvent e)
{String number=e.getActionCommand();
int n=Integer.parseInt(number);
int m=n*n*n;
System.out.println(n+"的立方:"+m);
}
}
public class Example1
{ public static void main(String args[])
{ YourWindow win=new YourWindow();
}
}
编译后就2个错误:C:\Documents and Settings\Administrator\My Documents\Example1.java:36: cannot resolve symbol
symbol : class YourWindow
location: class Example1
{ YourWindow win=new YourWindow();
^
C:\Documents and Settings\Administrator\My Documents\Example1.java:36: cannot resolve symbol
symbol : class YourWindow
location: class Example1
{ YourWindow win=new YourWindow();
^
2 errors
解决方案 »
- Java核心编程的例题,为什么总报数组下表溢出
- 看到一道很老的题,但是发现了有意思的答案
- 问下jasperreport 跟 jfreechat 报表软件,哪个好些!
- 怎么给JMenu添加图片
- 求教一个二分查找的程序
- 给大家推荐一个JAVASCRIPT站点,http://www.tutejs.cn,来这里可以看到很多JAVASCRIPT。
- JAVA新手出现了一个疑问,求大神指点一下,我好像没有那个什么悬赏分,刚注册没多久,别介意,希望谁教我一下。谢谢!
- 随机数问题,50分
- 低手请教一个关于import的问题。在线等待。
- 散分,不为什么
- 谁能解释一下->这个程序
- 关于String相关方法创建对象的问题?
这个YourWindow 和你的类名Yourwindow 不符改成Yourwindow win=new Yourwindow();
YourWindow
看出区别了吗?
用个ide,基本可以解决这些问题,比如eclipse
YourWindow