import java.awt.*;import java.awt.event.*;
public class Client extends Frame implements ActionListener
{
Client()
{
super("chat");
TextField text=new TextField();
TextArea teext=new TextArea();
this.setLocation(300, 200);
this.setSize(244, 366);
this.setResizable(false);
this.setBackground(Color.white);
this.add(text,BorderLayout.SOUTH);
this.add(teext,BorderLayout.NORTH);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
text.addActionListener(this);
public void actionPerformed(ActionEvent e)
{
String s=text.getText().trim();
teext.setText(s);
text.setText("");
}
this.pack();
this.setVisible(true);
}
}
在编译的时候说public void actionPerformed(ActionEvent e)是个非法表达式的开始 哪个大哥帮我解决下啊
public class Client extends Frame implements ActionListener
{
Client()
{
super("chat");
TextField text=new TextField();
TextArea teext=new TextArea();
this.setLocation(300, 200);
this.setSize(244, 366);
this.setResizable(false);
this.setBackground(Color.white);
this.add(text,BorderLayout.SOUTH);
this.add(teext,BorderLayout.NORTH);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
text.addActionListener(this);
public void actionPerformed(ActionEvent e)
{
String s=text.getText().trim();
teext.setText(s);
text.setText("");
}
this.pack();
this.setVisible(true);
}
}
在编译的时候说public void actionPerformed(ActionEvent e)是个非法表达式的开始 哪个大哥帮我解决下啊
楼主【zhaomaoyu】截止到2008-07-18 15:49:50的历史汇总数据(不包括此帖):
发帖的总数量:4 发帖的总分数:40 每贴平均分数:10
回帖的总数量:3 得分贴总数量:0 回帖的得分率:0%
结贴的总数量:4 结贴的总分数:40
无满意结贴数:0 无满意结贴分:0
未结的帖子数:0 未结的总分数:0
结贴的百分比:100.00% 结分的百分比:100.00%
无满意结贴率:0.00 % 无满意结分率:0.00 %
敬礼!
import java.awt.*;
import java.awt.event.*;public class Client extends Frame implements ActionListener {
private TextField text = new TextField();
private TextArea teext = new TextArea(); public Client()
{
super("chat"); this.setLocation(300, 200);
this.setSize(244, 366);
this.setResizable(false);
this.setBackground(Color.white);
this.add(text, BorderLayout.SOUTH);
this.add(teext, BorderLayout.NORTH);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
text.addActionListener(this);
this.pack();
this.setVisible(true);
} public void actionPerformed(ActionEvent e) {
String s = text.getText().trim();
teext.setText(s);
text.setText("");
}
}actionPerformed方法被写到构造方法里去了喵~``
import java.awt.event.*;
public class Client extends Frame implements ActionListener
{
public Client()
{
super("chat");
TextField text=new TextField();
TextArea teext=new TextArea();
this.setLocation(300, 200);
this.setSize(244, 366);
this.setResizable(false);
this.setBackground(Color.white);
this.add(text,BorderLayout.SOUTH);
this.add(teext,BorderLayout.NORTH);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
text.addActionListener(this); this.pack();
this.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
String s=text.getText().trim();
teext.setText(s);
text.setText("");
}}
import java.awt.event.*;
public class Client extends Frame implements ActionListener
{
public Client()
{
super("chat");
TextField text=new TextField();
TextArea teext=new TextArea();
this.setLocation(300, 200);
this.setSize(244, 366);
this.setResizable(false);
this.setBackground(Color.white);
this.add(text,BorderLayout.SOUTH);
this.add(teext,BorderLayout.NORTH);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
text.addActionListener(new ActionAdapter() public void actionPerformed(ActionEvent e)
{
String s=text.getText().trim();
teext.setText(s);
text.setText("");
}); this.pack();
this.setVisible(true);
}
}
import java.awt.event.*;public class Client extends Frame implements ActionListener { private TextField text = new TextField();
private TextArea teext = new TextArea(); public Client() {
super("chat"); this.setLocation(300, 200);
this.setSize(244, 366);
this.setResizable(false);
this.setBackground(Color.white);
this.add(text, BorderLayout.SOUTH);
this.add(teext, BorderLayout.NORTH);
addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
text.addActionListener(this);
this.pack();
this.setVisible(true);
} public void actionPerformed(ActionEvent e) {
String s = text.getText().trim();
teext.setText(s);
text.setText("");
}
public static void main(String[] args) {
new Client();
}
}
private TextArea teext = new TextArea();
为什么这里必须声明为private
其实整理一下程序谁都能看出问题来.....代码的规范很重要.特别是现在的软件开发都是将团队的.不规范的代码会影响开发的进度,维护,更新等问题....
作为一个初学的人.代码的规范是起码的.不要等到以后都习惯了再来改....那样自己会很难受的