当前位置: 技术问答>java相关
我的这个程序一直报错,高手一眼就能看明白,谢谢惠顾
来源: 互联网 发布时间:2017-04-11
本文导语: 报错信息: "login.java": Error #: 454 : class my_gupiao.login should be declared abstract; it does not define method actionPerformed(java.awt.event.ActionEvent) in interface java.awt.event.ActionListener at line 7, column 8 代码: package my_g...
报错信息:
"login.java": Error #: 454 : class my_gupiao.login should be declared abstract; it does not define method actionPerformed(java.awt.event.ActionEvent) in interface java.awt.event.ActionListener at line 7, column 8
代码:
package my_gupiao;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class login implements ActionListener{
JPanel p1,p2 ;
public login(){
JFrame j = new JFrame("login") ;
Container c = j.getContentPane() ;
c.setLayout(new GridLayout(2,1));
p1 = new JPanel() ;
p1.setLayout(new GridLayout(2,2));
JTextField jtf = new JTextField() ;
JPasswordField jpf = new JPasswordField() ;
p1.add(new JLabel("user:")) ;
p1.add(jtf) ;
p1.add(new JLabel("pass:")) ;
p1.add(jpf) ;
c.add(p1) ;
JButton jb = new JButton("login") ;
jb.addActionListener(this);
c.add(jb) ;
j.pack();
j.setVisible(true);
j.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
}
public void actionPerformed(ActiveEvent e){
new clientlook() ;
}
public static void main(String args[]){
new login() ;
}
}
"login.java": Error #: 454 : class my_gupiao.login should be declared abstract; it does not define method actionPerformed(java.awt.event.ActionEvent) in interface java.awt.event.ActionListener at line 7, column 8
代码:
package my_gupiao;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class login implements ActionListener{
JPanel p1,p2 ;
public login(){
JFrame j = new JFrame("login") ;
Container c = j.getContentPane() ;
c.setLayout(new GridLayout(2,1));
p1 = new JPanel() ;
p1.setLayout(new GridLayout(2,2));
JTextField jtf = new JTextField() ;
JPasswordField jpf = new JPasswordField() ;
p1.add(new JLabel("user:")) ;
p1.add(jtf) ;
p1.add(new JLabel("pass:")) ;
p1.add(jpf) ;
c.add(p1) ;
JButton jb = new JButton("login") ;
jb.addActionListener(this);
c.add(jb) ;
j.pack();
j.setVisible(true);
j.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
}
public void actionPerformed(ActiveEvent e){
new clientlook() ;
}
public static void main(String args[]){
new login() ;
}
}
|
我还有个问题,看看去吧。
主题:“JAVA布局问题”
主题:“JAVA布局问题”
|
hehe
|
up