import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
public class Deluser extends JDialog implements ActionListener
{
JLabel l_id,l_pass,l_error;
JTextField t_id;
JButton b_enter,b_cancle;
JPanel pan1,pan2,pan3,pan4;
JPasswordField t_pass;
String sname,spass;
NetConn sql;
Statement sqll;
ResultSet rs;
int until=1;
Deluser(Frame f,String s,Client client,Message msg)
{
//界面布局
super(f,s);
l_id=new JLabel("id:");
l_pass=new JLabel("密码:");
l_error=new JLabel("请输入用户名和密码删除");
t_id=new JTextField("",10);
t_pass=new JPasswordField("",10);
t_pass.setEchoChar('*');
b_enter=new JButton("确定");
b_enter.addActionListener(this);
b_cancle=new JButton("取消");
b_cancle.addActionListener(this);
pan1=new JPanel();
pan2=new JPanel();
pan3=new JPanel();
pan4=new JPanel();
pan1.add(l_id);pan1.add(t_id);
pan2.add(l_pass);pan2.add(t_pass);
pan3.add(l_error);
pan4.add(b_enter);pan4.add(b_cancle);
setLayout(new GridLayout(4,1));
add(pan1);add(pan2);add(pan3);add(pan4);
//建立数据库连接
sql=new NetConn();
//设置窗口大小
setBounds(400,200,300,300);
setVisible(false);
}
public void actionPerformed(ActionEvent e)
{
//单击确定按钮的事件处理程序
if(e.getSource()==b_enter)
{
sqll=sql.connect();
try
{
//根据用户名和密码删除指定用户
sqll.executeUpdate("delete from users where userid="+"'"+t_id.getText()+"'"+"and password="+"'"+t_pass.getText()+"'");
l_error.setText("用户删除成功");
}
catch(SQLException e2)
{}
}
else if(e.getSource()==b_cancle)
{
dispose();
}
}
}
它总出现这样的错误:
Description Resource Path Location Type
Client cannot be resolved to a type Deluser.java /library/src line 21 Java Problem
Description Resource Path Location Type
Message cannot be resolved to a type Deluser.java /library/src line 21 Java Problem
------解决方案--------------------
Deluser(Frame f,String s,Client client,Message msg)
这一句, client 有问题, 你看另外一个界面传值过来时写的什么、?
------解决方案--------------------
给出你怎么实例化这个类的代码。
------解决方案--------------------
- Java code
import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.sql.*;