求助改了半天不知道什么错误(初学者一个小程序问题)~~~ input.addaction(this);语句不能单独的出现在类中。除了声明变量,初始化的语句外,其它的语句必须放在方法内。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.applet.Applet;import java.awt.*;import java.awt.event.*;public class k extends Applet implements ActionListener{ Label prompt; TextField input; Label output; public void init() { prompt=new Label("Enter a character please:"); input=new TextField(3); output=new Label(" "); add(prompt); add(input); add(output); input.addActionListener(this);} public void actionPerformed(ActionEvent e) { output.setText("You've entered character"+e.toString()); }} CODE:import java.applet.Applet;import java.awt.*;import java.awt.event.*;public class SimpleGraphicsInOut extends Applet implements ActionListener{ Label prompt; TextField input; Label output; public void init() { prompt=new Label("Enter a character please:"); input=new TextField(3); output=new Label(" "); add(prompt); add(input); add(output); input.addActionListener(this);} } public void action Performed(ActionEvent e) { output.setText("You've entered character"+e.toString()); }} input.addaction(this);放好位置啊, fengxiarong707(蒋枫) 的代码没有错,只是类名与你原来的不一样。注意检查一下类名和源文件(.java)名是否一致。 public class SimpleGraphicsInOut extends Applet implements Action Listener改为public class SimpleGraphicsInOut extends Applet implements ActionListener myeclipse的debug--F5,F6的作用和F8一样 可不可以在一个JFrame中显示两个窗口 求JAVA实现SOA框架的简单代码 线程的问题 请教for循环参数问题 求输出1000以内的奇数 java与数据库的连接 为什么总出现指针异常? 用java程序高效的解压jar文件,希望指教 请教:有关JCreatorPro2.5的问题,用过的都请进来看一下吧~~~ 我需要一些swing的c/s方面的源代码,请问谁知道哪里有的下载 用快车下载jdk时出新问题 大家有没有碰到
import java.awt.*;
import java.awt.event.*;
public class k extends Applet implements ActionListener
{
Label prompt;
TextField input;
Label output;
public void init()
{
prompt=new Label("Enter a character please:");
input=new TextField(3);
output=new Label(" ");
add(prompt);
add(input);
add(output);
input.addActionListener(this);}
public void actionPerformed(ActionEvent e)
{
output.setText("You've entered character"+e.toString());
}
}
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class SimpleGraphicsInOut extends Applet implements ActionListener
{
Label prompt;
TextField input;
Label output;
public void init()
{
prompt=new Label("Enter a character please:");
input=new TextField(3);
output=new Label(" ");
add(prompt);
add(input);
add(output);
input.addActionListener(this);}
}
public void action Performed(ActionEvent e)
{
output.setText("You've entered character"+e.toString());
}
}
放好位置啊,
改为
public class SimpleGraphicsInOut extends Applet implements ActionListener