没有合适的资源?快使用搜索试试~ 我知道了~
饭卡管理系统(java).docx
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 86 浏览量
2022-06-22
05:39:44
上传
评论
收藏 76KB DOCX 举报
温馨提示
试读
11页
饭卡管理系统(java).docx饭卡管理系统(java).docx饭卡管理系统(java).docx饭卡管理系统(java).docx饭卡管理系统(java).docx饭卡管理系统(java).docx饭卡管理系统(java).docx饭卡管理系统(java).docx
资源推荐
资源详情
资源评论
package
mysql;
import java.awt.*;
import
java.awt.event.*;
import java.sql.*;
import
javax.swing.*;
class Login extends
JFrame
{
private static nal long serialVersionUID =
1L;
private static JFrame frame = new JFrame("学生饭卡管理系统登录界面");
private JButton submit = new JButton("登陆");
private JButton reset = new JButton("重
置");
private JButton assign=new JButton("注
册");
JLabel nameLab = new JLabel("用户
名:");
private JLabel passwdLab = new JLabel("密
码:");
private JLabel lab = new JLabel();
public JTextField nameText = new JTextField(20);
public JPasswordField passwdText = new
JPasswordField(20);
public Login(){}
public void login(){
nameLab.setBounds(60, 20,
100,20);
passwdLab.setBounds(60, 50,
100,20);
lab.setBounds(100, 90, 200,20);
nameText.setBounds(120, 20, 100,
20);
passwdText.setBounds(120, 50, 100,
20);
submit.setBounds(120, 120, 100, 30);
reset.setBounds(250, 50, 60, 20);
assign.setBounds(250,20,60,20);
//passwdText.setEchoChar('*');
frame.add(nameLab);
frame.add(passwdLa
b);
frame.add(lab)
;
frame.add(nameText);
frame.add(passwdTex
t);
frame.add(submit);
//用户名
//用户密码
frame.add(reset
);
frame.add(assign
);
frame.setSize(400, 220);
frame.setLocation(400,
250);
ImagePanel img = new
ImagePanel();
img.setBounds(0,0,400,20
0);
frame.add(img);
frame.setVisible(true
);
submit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent
e){
@SuppressWarnings("deprecatio
n")
String
String
passwd=passwdText.getText().toStrin
g();
name=nameText.getText();
try{
ResultSet
sqlRst=null;
Class.forName("com.mysql.jdbc.Driver
");
Connection
conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/
test1","root","123456");
Statement st= conn.createStatement();
String sql = "select * from user where
name='"+name+"' and
passwd='"+passwd+"';";
sqlRst=st.executeQuery(sql);
if(sqlRst.next()){
frame.dispose()
;
new
Fankajiemain();
}
else{
lab.setForeground(Color.re
d);
lab.setText("登陆失败! 密码或账号错误!");
}
}catch(ClassNotFoundException
e1){
e1.printStackTrace();
} catch (SQLException e1) {
// TODO Auto-generated catch
block
e1.printStackTrace();
}
}
});
assign.addActionListener(new
ActionListener(){
// 注册按钮,点击进入到第三层
界面 输入学号
public void actionPerformed(ActionEvent
e){
frame.dispose()
;
new Zhuce();
}
}
);
reset.addActionListener(new
ActionListener(){
// 重置按钮
//用户名重置
public void actionPerformed(ActionEvent
e){
nameText.setText("");
passwdText.setText(""
);
//密码重置
}
}
);
}
public static void main(String
args[]) {
Login log= new
Login();
log.login();
}
class ImagePanel extends
JLabel{
//构建一个图片容器
private static nal long serialVersionUID =
1L;
protected void paintComponent(Graphics
g){
super.paintComponent(
g);
ImageIcon img = new ImageIcon("D:\\
Login.jpg");
g.drawImage(img.getImage(),0,0,this);
}
}
}
剩余10页未读,继续阅读
资源评论
apple_51426592
- 粉丝: 9579
- 资源: 9658
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功