package p;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseMotionListener;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.swing.*;
import com.mysql.jdbc.Connection;
public class dl implements ActionListener{
JDialog jd;
JDialog jdt;
private JPasswordField mm;
private JTextField yhm;
JLabel l;
private int i;
public void Cgui() {
JFrame f=new JFrame("系统");
JPanel p=new JPanel();
JButton b1=new JButton("登陆");
JButton b5=new JButton("退出");
l=new JLabel(" 欢迎登录!!");
p.setLayout(new GridLayout(1,4));
f.add(p,"North");
p.add(b1);
p.add(b5);
b1.addActionListener(this);
b5.addActionListener(this);
f.add(l,"Center");
f.setBounds(200,200,400,200);
f.setResizable(false);
f.setVisible(true);
jd=this.denglu(f);
jdt=this.tuichu(f);}
public JDialog denglu(JFrame f){
JDialog d=new JDialog(f,"登录对话框",true);
JLabel note=new JLabel("请输入注册信息");
JPanel pa=new JPanel();
pa.setLayout(new GridLayout(2,1));
pa.add(new Label("用户名:"));
pa.add(new Label("密 码:"));
JPanel pb=new JPanel();
pb.setLayout(new GridLayout(2,1));
yhm=new JTextField();
mm=new JPasswordField();
mm.setEchoChar('*');
pb.add(yhm);
pb.add(mm);
JPanel pc=new JPanel();
pc.setLayout(new GridLayout(1,2));
JButton submit=new JButton("提交");
JButton cancel=new JButton("取消");
pc.add(submit);
pc.add(cancel);
submit.setActionCommand("submitlogin");
cancel.setActionCommand("cancellogin");
submit.addActionListener(this);
cancel.addActionListener(this);
d.add(note,"North");
d.add(pa,"West");
d.add(pb,"Center");
d.add(pc,"South");
d.setBounds(200, 150, 180, 120);
d.setResizable(false);
return d;}
public JDialog tuichu (JFrame f){
JDialog d=new JDialog(f,"确认退出对话框",true);
JLabel note=new JLabel("你确定要退出程序吗?");
JPanel jp=new JPanel();
jp.setLayout(new FlowLayout());
JButton yes=new JButton("确定");
JButton no=new JButton("取消");
yes.setActionCommand("yesyes");
no.setActionCommand("nono");
yes.addActionListener(this);
no.addActionListener(this);
jp.add(note,"Center");
JPanel jp2=new JPanel();
jp2.add(yes);
jp2.add(no);
d.add(jp);
d.add(jp2,"South");
d.setBounds(200, 200, 180, 120);
d.setResizable(false);
return d;}
public static void main(String[] args) {
new dl().Cgui();
try {
Class.forName("com.mysql.jdbc.Driver");
String url="jdbc:mysql://localhost:3306/jxgl";
String un="root";
String psw="root";
try {
java.sql.Connection conn=DriverManager.getConnection(url,un,psw);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();}
}
public void actionPerformed(ActionEvent e){
String s=e.getActionCommand();
if(s.equals("登陆"))
jd.setVisible(true);
else if(s.equals("退出"))
jdt.setVisible(true);
else if(s.equals("submitlogin")){
String name=yhm.getText();
String password=mm.getText();
if((name.equals("1")||name.equals("希诺"))&&password.equals("123123")){
l.setText("登录成功!你的用户名是 "+name+" 您有权限处理数据库中的内容!!");
jd.setVisible(false);
JFrame f=new JFrame("管理");
JTabbedPane jp=new JTabbedPane(JTabbedPane.TOP);
Panel p2=new Panel();
Panel p3=new Panel();
Panel p4=new Panel();
Panel p5=new Panel();
Panel p6=new Panel();
JButton b2=new JButton("添加");
JButton b3=new JButton("查看");
JButton b4=new JButton("修改");
JButton b20=new JButton("删除");
JButton b5=new JButton("添加");
JButton b6=new JButton("查看");
JButton b7=new JButton("修改");
JButton b21=new JButton("删除");
JButton b8=new JButton("添加");
JButton b9=new JButton("查看");
JButton b0=new JButton("修改");
JButton b22=new JButton("删除");
JButton b11=new JButton("添加");
JButton b12=new JButton("查看");
JButton b13=new JButton("修改");
JButton b23=new JButton("删除");
JButton b14=new JButton("添加");
JButton b15=new JButton("查看");
JButton b16=new JButton("修改");
JButton b24=new JButton("删除");
p2.add(b2);
p2.add(b3);
p2.add(b4);
p2.add(b20);
p3.add(b5);
p3.add(b6);
p3.add(b7);
p3.add(b21);
p4.add(b8);
p4.add(b9);
p4.add(b0);
p4.add(b22);
p5.add(b11);
p5.add(b12);
p5.add(b13);
p5.add(b23);
p6.add(b14);
p6.add(b15);
p6.add(b16);
p6.add(b24);
jp.add("学生管理",p2);
jp.add("教师管理",p3);
jp.add("课程管理",p4);
jp.add("成绩管理",p5);
jp.add("用户管理",p6);
f.add(jp);
f.setBounds(300, 300,600, 200);
f.setResizable(false);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true); }
else{
l.setText("登陆失败,用户名或者密码不正确");}
}
else if(s.equals("cancellogin"))
jd.setVisible(false);
else if(s.equals("yesyes"))
System.exit(0);
else if(s.equals("nono"))
jdt.setVisible(false);
}
}
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseMotionListener;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.swing.*;
import com.mysql.jdbc.Connection;
public class dl implements ActionListener{
JDialog jd;
JDialog jdt;
private JPasswordField mm;
private JTextField yhm;
JLabel l;
private int i;
public void Cgui() {
JFrame f=new JFrame("系统");
JPanel p=new JPanel();
JButton b1=new JButton("登陆");
JButton b5=new JButton("退出");
l=new JLabel(" 欢迎登录!!");
p.setLayout(new GridLayout(1,4));
f.add(p,"North");
p.add(b1);
p.add(b5);
b1.addActionListener(this);
b5.addActionListener(this);
f.add(l,"Center");
f.setBounds(200,200,400,200);
f.setResizable(false);
f.setVisible(true);
jd=this.denglu(f);
jdt=this.tuichu(f);}
public JDialog denglu(JFrame f){
JDialog d=new JDialog(f,"登录对话框",true);
JLabel note=new JLabel("请输入注册信息");
JPanel pa=new JPanel();
pa.setLayout(new GridLayout(2,1));
pa.add(new Label("用户名:"));
pa.add(new Label("密 码:"));
JPanel pb=new JPanel();
pb.setLayout(new GridLayout(2,1));
yhm=new JTextField();
mm=new JPasswordField();
mm.setEchoChar('*');
pb.add(yhm);
pb.add(mm);
JPanel pc=new JPanel();
pc.setLayout(new GridLayout(1,2));
JButton submit=new JButton("提交");
JButton cancel=new JButton("取消");
pc.add(submit);
pc.add(cancel);
submit.setActionCommand("submitlogin");
cancel.setActionCommand("cancellogin");
submit.addActionListener(this);
cancel.addActionListener(this);
d.add(note,"North");
d.add(pa,"West");
d.add(pb,"Center");
d.add(pc,"South");
d.setBounds(200, 150, 180, 120);
d.setResizable(false);
return d;}
public JDialog tuichu (JFrame f){
JDialog d=new JDialog(f,"确认退出对话框",true);
JLabel note=new JLabel("你确定要退出程序吗?");
JPanel jp=new JPanel();
jp.setLayout(new FlowLayout());
JButton yes=new JButton("确定");
JButton no=new JButton("取消");
yes.setActionCommand("yesyes");
no.setActionCommand("nono");
yes.addActionListener(this);
no.addActionListener(this);
jp.add(note,"Center");
JPanel jp2=new JPanel();
jp2.add(yes);
jp2.add(no);
d.add(jp);
d.add(jp2,"South");
d.setBounds(200, 200, 180, 120);
d.setResizable(false);
return d;}
public static void main(String[] args) {
new dl().Cgui();
try {
Class.forName("com.mysql.jdbc.Driver");
String url="jdbc:mysql://localhost:3306/jxgl";
String un="root";
String psw="root";
try {
java.sql.Connection conn=DriverManager.getConnection(url,un,psw);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();}
}
public void actionPerformed(ActionEvent e){
String s=e.getActionCommand();
if(s.equals("登陆"))
jd.setVisible(true);
else if(s.equals("退出"))
jdt.setVisible(true);
else if(s.equals("submitlogin")){
String name=yhm.getText();
String password=mm.getText();
if((name.equals("1")||name.equals("希诺"))&&password.equals("123123")){
l.setText("登录成功!你的用户名是 "+name+" 您有权限处理数据库中的内容!!");
jd.setVisible(false);
JFrame f=new JFrame("管理");
JTabbedPane jp=new JTabbedPane(JTabbedPane.TOP);
Panel p2=new Panel();
Panel p3=new Panel();
Panel p4=new Panel();
Panel p5=new Panel();
Panel p6=new Panel();
JButton b2=new JButton("添加");
JButton b3=new JButton("查看");
JButton b4=new JButton("修改");
JButton b20=new JButton("删除");
JButton b5=new JButton("添加");
JButton b6=new JButton("查看");
JButton b7=new JButton("修改");
JButton b21=new JButton("删除");
JButton b8=new JButton("添加");
JButton b9=new JButton("查看");
JButton b0=new JButton("修改");
JButton b22=new JButton("删除");
JButton b11=new JButton("添加");
JButton b12=new JButton("查看");
JButton b13=new JButton("修改");
JButton b23=new JButton("删除");
JButton b14=new JButton("添加");
JButton b15=new JButton("查看");
JButton b16=new JButton("修改");
JButton b24=new JButton("删除");
p2.add(b2);
p2.add(b3);
p2.add(b4);
p2.add(b20);
p3.add(b5);
p3.add(b6);
p3.add(b7);
p3.add(b21);
p4.add(b8);
p4.add(b9);
p4.add(b0);
p4.add(b22);
p5.add(b11);
p5.add(b12);
p5.add(b13);
p5.add(b23);
p6.add(b14);
p6.add(b15);
p6.add(b16);
p6.add(b24);
jp.add("学生管理",p2);
jp.add("教师管理",p3);
jp.add("课程管理",p4);
jp.add("成绩管理",p5);
jp.add("用户管理",p6);
f.add(jp);
f.setBounds(300, 300,600, 200);
f.setResizable(false);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true); }
else{
l.setText("登陆失败,用户名或者密码不正确");}
}
else if(s.equals("cancellogin"))
jd.setVisible(false);
else if(s.equals("yesyes"))
System.exit(0);
else if(s.equals("nono"))
jdt.setVisible(false);
}
}