当前位置: 技术问答>java相关
照书抄了个程序都出错,哪位朋友帮我找找错?
来源: 互联网 发布时间:2015-09-03
本文导语: package input; import java.awt.*; import java.awt.event.*; /** * Title: * Description: * Copyright: Copyright (c) 2002 * Company: * @author unascribed * @version 1.0 */ public class myjava { public static void main(String args[]) { ...
package input;
import java.awt.*;
import java.awt.event.*;
/**
*
*
*
*
* @author unascribed
* @version 1.0
*/
public class myjava
{
public static void main(String args[])
{
new FrameInOut();
}
class FrameInOut extends Frame implements ActionListener
{
Label prompt;
TextField input,output;
FrameInOut()
{
super("sdfjsdfjsk");
prompt=new Label("skjdfksj");
input=new TextField(6);
output=new TextField(20);
setLayout(new FlowLayout());
add(prompt);
add(input);
add(output);
input.addActionListener(this);
setSize(300,200);
show();
}
public void actionPerformed(ActionEvent e)
{
output.setText(input.getText()+"skfdj");
}
}
}
import java.awt.*;
import java.awt.event.*;
/**
*
Title:
*
Description:
*
Copyright: Copyright (c) 2002
*
Company:
* @author unascribed
* @version 1.0
*/
public class myjava
{
public static void main(String args[])
{
new FrameInOut();
}
class FrameInOut extends Frame implements ActionListener
{
Label prompt;
TextField input,output;
FrameInOut()
{
super("sdfjsdfjsk");
prompt=new Label("skjdfksj");
input=new TextField(6);
output=new TextField(20);
setLayout(new FlowLayout());
add(prompt);
add(input);
add(output);
input.addActionListener(this);
setSize(300,200);
show();
}
public void actionPerformed(ActionEvent e)
{
output.setText(input.getText()+"skfdj");
}
}
}
|
把最后一行的"}"移到
class FrameInOut extends Frame implements ActionListener
之前
class FrameInOut extends Frame implements ActionListener
之前
|
class FrameInOut应该是静态类,在前面加static即可运行了。
static class FrameInOut extends Frame implements ActionListener
static class FrameInOut extends Frame implements ActionListener