代码拉取完成,页面将自动刷新
package rjgc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class BaseDao {
protected static String dbClassName = "com.mysql.cj.jdbc.Driver";
protected static String dbUrl = "jdbc:mysql://localhost:3306/supermarket?useUnicode=true&characterEncoding=utf8&useSSL=true&serverTimezone=UTC";
protected static String dbUser = "root";
protected static String dbPwd = "123456";
public static Connection conn = null;
static {
try {
if (conn == null) {
Class.forName(dbClassName).newInstance();
conn = DriverManager.getConnection(dbUrl, dbUser, dbPwd);
}
} catch (Exception ee) {
ee.printStackTrace();
}
}
private BaseDao() {
}
// 读取顾客
public static customer getCus(String card) {
customer cus = new customer();
ResultSet rs = findForResultSet("select * from customer where card='"
+ card + "'");
try {
if (rs.next()) {
cus.setCard(card);
cus.setPassword(rs.getString("password"));
cus.setName(rs.getString("name"));
cus.setDate(rs.getString("RegistDate"));
cus.setScore(rs.getInt("score"));
cus.setId(rs.getInt("id"));
}
} catch (SQLException e) {
e.printStackTrace();
}
return cus;
}
public static ResultSet findForResultSet(String sql) {
if (conn == null)
return null;
ResultSet rs = null;
Statement stmt = null;
try {
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
rs = stmt.executeQuery(sql);
} catch (Exception e) {
e.printStackTrace();
}
return rs;
}
// 执行指定查询
public static ResultSet query(String QueryStr) {
ResultSet set = findForResultSet(QueryStr);
return set;
}
//添加商品
public static boolean addThing(thing th) {
if (th == null)
return false;
else
return insert("insert into thing values('" + th.getId() + "','"
+ th.getName() +"','"+ th.getScore()+ "')");
}
//添加顾客
public static boolean addCus(customer cus) {
if (cus == null)
return false;
else
return insert("insert into customer values('" + cus.getId() + "','"
+ cus.getName() + "','" + cus.getCard() + "','"
+ cus.getPassword() + "','" + cus.getScore() + "','"
+ cus.getDate() + "')");
}
//添加操作
public static boolean insert(String sql) {
boolean result = false;
try {
Statement stmt = conn.createStatement();
result = stmt.execute(sql);
} catch (SQLException e) {
e.printStackTrace();
}
return result;
}
// 修改顾客积分信息的方法
public static int updateCus(int card,int score) {
return update("update customer set score = score+'" + score + "' where Card='" + card + "'");
}
//修改操作
public static int update(String sql) {
int result = 0;
try {
Statement stmt = conn.createStatement();
result = stmt.executeUpdate(sql);
} catch (SQLException e) {
e.printStackTrace();
}
return result;
}
//返回商品最大id
public static int getThingMaxId( String table,String idName) {
int id=0;
String sql = "select max(" + idName + ") from " + table;
try {
Statement stmt = conn.createStatement();
ResultSet set = stmt.executeQuery(sql);
if (set.next())
id = set.getInt(1);
} catch (SQLException e1) {
// TODO 自动生成的 catch 块
e1.printStackTrace();
}
return id;
}
//返回顾客最大id
public static int getCustomerMaxId( String table,String idName) {
int id=0;
String sql = "select max(" + idName + ") from " + table;
try {
Statement stmt = conn.createStatement();
ResultSet set = stmt.executeQuery(sql);
if (set.next())
id = set.getInt(1);
} catch (SQLException e1) {
// TODO 自动生成的 catch 块
e1.printStackTrace();
}
return id;
}
}
import java.util.Date;
public class customer {
private int id;
private String name;
private String card;
private int score;
private String password;
private String registDate;
public customer() {
}
public customer(int id) {
this.id = id;
}
public customer(int id,String name,String card,int score,String password,String registDate) {
this.id = id;
this.name = name;
this.card=card;
this.score=score;
this.password=password;
this.registDate=registDate;
}
public void setId(int id) {
this.id = id;
}
public int getId() {
return id;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setCard(String card) {
this.card = card;
}
public String getCard() {
return card;
}
public void setScore(int score) {
this.score = score;
}
public int getScore() {
return score;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getDate() {
return registDate;
}
public void setDate(String registDate) {
this.registDate = registDate;
}
}
package rjgc;
public class test {
public static void main(String[] args) {
// TODO 自动生成的方法存根
new mainWindow();
}
}
package rjgc;
public class thing {
private int id;
private String name;
private int score;
public thing() {
}
public thing(int id) {
this.id=id;
}
public thing(int id,String name,int score) {
this.id=id;
this.name=name;
this.score=score;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id=id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name=name;
}
public int getScore() {
return score;
}
public void setScore(int score) {
this.score=score;
}
}
package rjgc;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class Window extends JDialog{
public Window(WindowS frame) {
super(frame,"用户卡号",true);//实例化一个JDialog类对象,指定对话框的父窗体、窗体标题和类型
setBounds(220,220,500,300);//设置窗体坐标和大小
setTitle("收银员系统");
setLayout(null);
Container c = getContentPane();
JLabel l = new JLabel("-----欢迎进入收银员界面-----");//创建一个标签
l.setBounds(150, 10, 300, 30);
c.add(l);//窗体中添加标签
JLabel l1 = new JLabel("会员卡号");
l1.setBounds(10, 60, 60, 20);
c.add(l1);
JLabel l2 = new JLabel("消费金额");
l2.setBounds(10, 100, 60, 20);
c.add(l2);
JTextField jt1 = new JTextField();
jt1.setBounds(80, 60, 200, 20);
c.add(jt1);
JTextField jt2 = new JTextField();
jt2.setBounds(80, 100, 200, 20);
c.add(jt2);
JButton btn1= new JButton("确定");
btn1.setBounds(150, 150, 60, 20);
c.add(btn1);
JButton btn2= new JButton("取消");
btn2.setBounds(250, 150, 60, 20);
c.add(btn2);
btn1.addActionListener(new ActionListener() {//为按钮添加鼠标单击事件
public void actionPerformed(ActionEvent e) {
String str1=jt1.getText();
String str2=jt2.getText();
int card=Integer.parseInt(str1);
int score=Integer.parseInt(str2);
if(BaseDao.updateCus(card, score)==1)
new WindowW(Window.this,"成功!").setVisible(true);
else
new WindowW(Window.this,"失败!").setVisible(true);
}
});
}
class WindowW extends JDialog{
public WindowW(Window frame,String s) {
super(frame,s,true);//实例化一个JDialog类对象,指定对话框的父窗体、窗体标题和类型
setBounds(250,250,400,250);//设置对话框窗体大小
Container c = getContentPane();//创建一个容器
setLayout(null);
JLabel l1 = new JLabel(s);
l1.setBounds(80, 60, 200, 20);
c.add(l1);
}
}
}
package rjgc;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
public class Window1 extends JDialog{
public Window1(WindowS2 frame) {
super(frame,"开卡系统",true);//实例化一个JDialog类对象,指定对话框的父窗体、窗体标题和类型
setLayout(null);
Container c = getContentPane();
setBounds(230,230,500,300);//设置窗体坐标和大小
JLabel l = new JLabel("-----欢迎进入开卡界面-----");//创建一个标签
l.setBounds(150, 10, 300, 30);
c.add(l);//窗体中添加标签
JLabel l1 = new JLabel("姓名");
l1.setBounds(10, 60, 60, 20);
c.add(l1);
JLabel l2 = new JLabel("密码");
l2.setBounds(10, 100, 60, 20);
c.add(l2);
JLabel l3 = new JLabel("确认密码");
l3.setBounds(10, 140, 60, 20);
c.add(l3);
JTextField jt = new JTextField();
jt.setBounds(80, 60, 200, 20);
c.add(jt);
JPasswordField jp1=new JPasswordField();
jp1.setBounds(80, 100, 200, 20);
c.add(jp1);
JPasswordField jp2=new JPasswordField();
jp2.setBounds(80, 140, 200, 20);
c.add(jp2);
JButton btn1= new JButton("确定");
btn1.setBounds(150, 180, 60, 20);
c.add(btn1);
JButton btn2= new JButton("取消");
btn2.setBounds(250, 180, 60, 20);
c.add(btn2);
btn1.addActionListener(new ActionListener() {//为按钮添加鼠标单击事件
public void actionPerformed(ActionEvent e) {
char ch1[] = jp1.getPassword();//获取密码的字符数组
String str1=new String(ch1);
char ch2[] = jp2.getPassword();//获取密码的字符数组
String str2=new String(ch2);
if(jt.getText().equals(""))
{
new win1(Window1.this).setVisible(true);//使MYJDialog窗体可见
}
else if(str1.equals(""))
{
new win2(Window1.this).setVisible(true);//使MYJDialog窗体可见
}
else if(str1.equals(str2))
{
int id=BaseDao.getCustomerMaxId("customer", "ID")+1;
int score=0;
String name=jt.getText();
//注册日期
Date date = new Date();
SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd :hh:mm:ss");
String rdate = dateFormat.format(date);
String password=str1;
String card=id+"";
customer cus=new customer(id,name,card,score,password,rdate);
BaseDao.addCus(cus);
new MyJDialog(Window1.this,cus).setVisible(true);//使MYJDialog窗体可见
}
else
{
new win(Window1.this).setVisible(true);//使MYJDialog窗体可见
}
}
});
}
class MyJDialog extends JDialog{
public MyJDialog(Window1 frame,customer cus)
{
super(frame,"用户卡号",true);//实例化一个JDialog类对象,指定对话框的父窗体、窗体标题和类型
setBounds(250,250,400,200);//设置对话框窗体大小
Container c = getContentPane();//创建一个容器
setLayout(null);
JLabel l1 = new JLabel("请记住卡号 : "+cus.getCard());
l1.setBounds(50, 60, 200, 20);
c.add(l1);
}
}
class win extends JDialog{
public win(Window1 frame) {
super(frame,"错误!!!",true);//实例化一个JDialog类对象,指定对话框的父窗体、窗体标题和类型
setBounds(250,250,400,250);//设置对话框窗体大小
Container c = getContentPane();//创建一个容器
setLayout(null);
JLabel l1 = new JLabel("确认密码错误!");
l1.setBounds(80, 60, 200, 20);
c.add(l1);
}
}
class win1 extends JDialog{
public win1(Window1 frame) {
super(frame,"错误!!!",true);//实例化一个JDialog类对象,指定对话框的父窗体、窗体标题和类型
setBounds(250,250,400,250);//设置对话框窗体大小
Container c = getContentPane();//创建一个容器
setLayout(null);
JLabel l1 = new JLabel("姓名不能为空!");
l1.setBounds(100, 60, 200, 20);
c.add(l1);
}
}
class win2 extends JDialog{
public win2(Window1 frame) {
super(frame,"错误!!!",true);//实例化一个JDialog类对象,指定对话框的父窗体、窗体标题和类型
setBounds(250,250,400,250);//设置对话框窗体大小
Container c = getContentPane();//创建一个容器
setLayout(null);
JLabel l1 = new JLabel("密码不能为空!");
l1.setBounds(100, 60, 200, 20);
c.add(l1);
}
}
}
package rjgc;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
public class WindowS extends JDialog{
public WindowS(mainWindow frame) {
super(frame,"验证界面",true);//实例化一个JDialog类对象,指定对话框的父窗体、窗体标题和类型
setBounds(210,210,500,280);//设置窗体坐标和大小
setLayout(null);
Container c = getContentPane();
JLabel l = new JLabel("-----请验证你的身份-----");//创建一个标签
l.setBounds(150, 10, 300, 30);
c.add(l);//窗体中添加标签
JLabel l1 = new JLabel("你的口令:");
l1.setBounds(10, 80, 80, 20);
c.add(l1);
JPasswordField jp=new JPasswordField();
jp.setBounds(120, 80, 200, 20);
c.add(jp);
JButton btn1= new JButton("确定");
btn1.setBounds(150, 150, 60, 20);
c.add(btn1);
JButton btn2= new JButton("取消");
btn2.setBounds(250, 150, 60, 20);
c.add(btn2);
btn1.addActionListener(new ActionListener() {//为按钮添加鼠标单击事件
public void actionPerformed(ActionEvent e) {
char ch[] = jp.getPassword();//获取密码的字符数组
String str=new String(ch);
if(str.equals("password"))
new Window(WindowS.this).setVisible(true);
else
new WindowS1(WindowS.this).setVisible(true);
}
});
}
}
package rjgc;
import java.awt.Container;
import javax.swing.JDialog;
import javax.swing.JLabel;
public class WindowS1 extends JDialog{
public WindowS1(WindowS frame) {
super(frame,"错误!!!",true);//实例化一个JDialog类对象,指定对话框的父窗体、窗体标题和类型
setBounds(220,220,300,200);//设置窗体坐标和大小
setLayout(null);
Container c = getContentPane();
JLabel l = new JLabel("口令错误!!!请重新输入!");//创建一个标签
l.setBounds(30, 50, 300, 30);
c.add(l);//窗体中添加标签
}
}
package rjgc;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
public class WindowS2 extends JDialog{
public WindowS2(mainWindow frame) {
super(frame,"用户界面",true);//实例化一个JDialog类对象,指定对话框的父窗体、窗体标题和类型
setBounds(220,220,500,300);//设置窗体坐标和大小
setLayout(null);
Container c = getContentPane();
JLabel l = new JLabel("-----欢迎进入用户界面-----");//创建一个标签
l.setBounds(150, 10, 300, 30);
c.add(l);//窗体中添加标签
JRadioButton jr1=new JRadioButton("开卡");
JRadioButton jr2=new JRadioButton("查询积分");
JRadioButton jr3=new JRadioButton("修改密码");
jr1.setBounds(20, 70, 80, 20);
jr2.setBounds(120, 70, 80, 20);
jr3.setBounds(220, 70, 80, 20);
jr1.setSelected(true);
ButtonGroup group=new ButtonGroup();
group.add(jr1);
group.add(jr2);
group.add(jr3);
c.add(jr1);
c.add(jr2);
c.add(jr3);
JButton btn1= new JButton("确定");
btn1.setBounds(150, 150, 60, 20);
c.add(btn1);
JButton btn2= new JButton("取消");
btn2.setBounds(250, 150, 60, 20);
c.add(btn2);
btn1.addActionListener(new ActionListener() {//为按钮添加鼠标单击事件
public void actionPerformed(ActionEvent e) {
if(jr1.isSelected())
new Window1(WindowS2.this).setVisible(true);
else if(jr2.isSelected())
new WindowS3(WindowS2.this).setVisible(true);
else
new WindowS4(WindowS2.this).setVisible(true);
}
});
}
}
package rjgc;
import java.awt.Container;
import javax.swing.JDialog;
import javax.swing.JLabel;
public class WindowS3 extends JDialog{
public WindowS3(WindowS2 frame) {
super(frame,"查询积分",true);//实例化一个JDialog类对象,指定对话框的父窗体、窗体标题和类型
setBounds(250,250,300,200);//设置窗体坐标和大小
setLayout(null);
Container c = getContentPane();
JLabel l1 = new JLabel("积分:");
l1.setBounds(10, 50, 80, 20);
c.add(l1);
}
}
package rjgc;
import java.awt.Container;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
public class WindowS4 extends JDialog{
public WindowS4(WindowS2 frame) {
super(frame,"修改密码",true);//实例化一个JDialog类对象,指定对话框的父窗体、窗体标题和类型
setBounds(250,250,500,300);//设置窗体坐标和大小
setLayout(null);
Container c = getContentPane();
JLabel l1 = new JLabel("旧密码:");
l1.setBounds(30, 50, 80, 20);
c.add(l1);
JLabel l2 = new JLabel("新密码:");
l2.setBounds(30, 100, 80, 20);
c.add(l2);
JPasswordField jp1=new JPasswordField();
jp1.setBounds(120, 50, 200, 20);
c.add(jp1);
JPasswordField jp2=new JPasswordField();
jp2.setBounds(120, 100, 200, 20);
c.add(jp2);
JButton btn1= new JButton("确定");
btn1.setBounds(150, 160, 60, 20);
c.add(btn1);
JButton btn2= new JButton("取消");
btn2.setBounds(250, 160, 60, 20);
c.add(btn2);
}
}
package rjgc;
import java.awt.Container;
import javax.swing.JDialog;
import javax.swing.JLabel;
public class WindowS11 extends JDialog{
public WindowS11(WindowSS frame) {
super(frame,"错误!!!",true);//实例化一个JDialog类对象,指定对话框的父窗体、窗体标题和类型
setBounds(220,220,300,200);//设置窗体坐标和大小
setLayout(null);
Container c = getContentPane();
JLabel l = new JLabel("口令错误!!!请重新输入!");//创建一个标签
l.setBounds(30, 50, 300, 30);
c.add(l);//窗体中添加标签
}
}
package rjgc;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
public class WindowS22 extends JDialog{
public WindowS22(WindowSS frame) {
super(frame,"管理员界面",true);//实例化一个JDialog类对象,指定对话框的父窗体、窗体标题和类型
setBounds(220,220,500,300);//设置窗体坐标和大小
setLayout(null);
Container c = getContentPane();
JLabel l = new JLabel("-----欢迎进入管理员界面-----");//创建一个标签
l.setBounds(150, 10, 300, 30);
c.add(l);//窗体中添加标签
JRadioButton jr1=new JRadioButton("添加兑换商品");
JRadioButton jr2=new JRadioButton("修改兑换商品");
JRadioButton jr3=new JRadioButton("删除兑换商品");
jr1.setBounds(20, 90, 120, 20);
jr2.setBounds(150, 90, 120, 20);
jr3.setBounds(280, 90, 120, 20);
jr1.setSelected(true);
ButtonGroup group=new ButtonGroup();
group.add(jr1);
group.add(jr2);
group.add(jr3);
c.add(jr1);
c.add(jr2);
c.add(jr3);
JButton btn1= new JButton("确定");
btn1.setBounds(150, 160, 60, 20);
c.add(btn1);
JButton btn2= new JButton("取消");
btn2.setBounds(250, 160, 60, 20);
c.add(btn2);
btn1.addActionListener(new ActionListener() {//为按钮添加鼠标单击事件
public void actionPerformed(ActionEvent e) {
if(jr1.isSelected())
new WindowS221(WindowS22.this).setVisible(true);
// else if(jr2.isSelected())
// new WindowS222(WindowS22.this).setVisible(true);
// else
// new WindowS223(WindowS22.this).setVisible(true);
}
});
}
}
package rjgc;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JTextField;
import rjgc.Window1.MyJDialog;
public class WindowS221 extends JDialog{
public WindowS221(WindowS22 frame) {
super(frame,"添加兑换商品",true);//实例化一个JDialog类对象,指定对话框的父窗体、窗体标题和类型
setBounds(250,250,500,300);//设置窗体坐标和大小
setLayout(null);
Container c = getContentPane();
JLabel l = new JLabel("-----欢迎进入添加兑换商品界面-----");//创建一个标签
l.setBounds(150, 10, 300, 30);
c.add(l);//窗体中添加标签
JLabel l1 = new JLabel("商品名");
l1.setBounds(10, 60, 60, 20);
c.add(l1);
JLabel l2 = new JLabel("兑换积分");
l2.setBounds(10, 100, 60, 20);
c.add(l2);
JTextField jt1 = new JTextField();
jt1.setBounds(80, 60, 200, 20);
c.add(jt1);
JTextField jt2 = new JTextField();
jt2.setBounds(80, 100, 200, 20);
c.add(jt2);
JButton btn1= new JButton("确定");
btn1.setBounds(150, 150, 60, 20);
c.add(btn1);
JButton btn2= new JButton("取消");
btn2.setBounds(250, 150, 60, 20);
c.add(btn2);
btn1.addActionListener(new ActionListener() {//为按钮添加鼠标单击事件
public void actionPerformed(ActionEvent e) {
String str1=jt1.getText();
String str2=jt2.getText();
if(str1.equals(""))
{
new win1(WindowS221.this).setVisible(true);
}
else if(str2.equals(""))
{
new win2(WindowS221.this).setVisible(true);
}
else
{
int id=BaseDao.getThingMaxId("thing", "ID")+1;
String name=str1;
int score=Integer.parseInt(str2);
thing th=new thing(id,name,score);
BaseDao.addThing(th);
ResultSet haveCus = BaseDao.query("select * from customer where id='" + id + "'");
try {
if(haveCus.next())
new MyJDialog(WindowS221.this,"添加成功!").setVisible(true);
else
new MyJDialog(WindowS221.this,"添加失败!").setVisible(true);
} catch (SQLException e1) {
// TODO 自动生成的 catch 块
e1.printStackTrace();
}
}
}
});
}
class MyJDialog extends JDialog{
public MyJDialog(WindowS221 frame,String s)
{
super(frame,"提示",true);//实例化一个JDialog类对象,指定对话框的父窗体、窗体标题和类型
setBounds(270,270,300,200);//设置对话框窗体大小
Container c = getContentPane();//创建一个容器
setLayout(null);
JLabel l1 = new JLabel(s);
l1.setBounds(80, 60, 200, 20);
c.add(l1);
}
}
class win1 extends JDialog{
public win1(WindowS221 frame) {
super(frame,"错误!!!",true);//实例化一个JDialog类对象,指定对话框的父窗体、窗体标题和类型
setBounds(250,250,400,250);//设置对话框窗体大小
Container c = getContentPane();//创建一个容器
setLayout(null);
JLabel l1 = new JLabel("商品名不能为空!");
l1.setBounds(100, 60, 200, 20);
c.add(l1);
}
}
class win2 extends JDialog{
public win2(WindowS221 frame) {
super(frame,"错误!!!",true);//实例化一个JDialog类对象,指定对话框的父窗体、窗体标题和类型
setBounds(250,250,400,250);//设置对话框窗体大小
Container c = getContentPane();//创建一个容器
setLayout(null);
JLabel l1 = new JLabel("兑换积分不能为空!");
l1.setBounds(100, 60, 200, 20);
c.add(l1);
}
}
}
package rjgc;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
public class WindowSS extends JDialog{
public WindowSS(mainWindow frame) {
super(frame,"验证界面",true);//实例化一个JDialog类对象,指定对话框的父窗体、窗体标题和类型
setBounds(210,210,500,280);//设置窗体坐标和大小
setLayout(null);
Container c = getContentPane();
JLabel l = new JLabel("-----请验证你的身份-----");//创建一个标签
l.setBounds(150, 10, 300, 30);
c.add(l);//窗体中添加标签
JLabel l1 = new JLabel("你的口令:");
l1.setBounds(10, 80, 80, 20);
c.add(l1);
JPasswordField jp=new JPasswordField();
jp.setBounds(120, 80, 200, 20);
c.add(jp);
JButton btn1= new JButton("确定");
btn1.setBounds(150, 150, 60, 20);
c.add(btn1);
JButton btn2= new JButton("取消");
btn2.setBounds(250, 150, 60, 20);
c.add(btn2);
btn1.addActionListener(new ActionListener() {//为按钮添加鼠标单击事件
public void actionPerformed(ActionEvent e) {
char ch[] = jp.getPassword();//获取密码的字符数组
String str=new String(ch);
if(str.equals("pass"))
new WindowS22(WindowSS.this).setVisible(true);
else
new WindowS11(WindowSS.this).setVisible(true);
}
});
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。