import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.sql.*;
import javax.swing.*;
import javax.swing.event.*;
class Login extends Frame implements ActionListener
{
MenuBar menubar;
Panel p1,p2,p3;
Label l1,l2;
TextField text1,text2;
Button b1,b2;
Login(String s,int a,int b)
{
super(s);
setSize(a,b);
setResizable(false); //ハケラ鋗ッエーソレア莎ノサメノォ
p1=new Panel();
p2=new Panel();
p3=new Panel();
setLayout(new GridLayout(1,3));//2ミミ3チミ
l1=new Label("ユヒコナ:");
l2=new Label("テワツ・");
text1=new TextField(10);
text2=new TextField(10);
text2.setEchoChar('*');
b1=new Button("ネキネマ");
b2=new Button("ネ。マ・);
setMenuBar(menubar);
setBackground(Color.white);
setVisible(true);
p1.setLayout(new GridLayout(4,1));
p1.add(new Label());p1.add(l1);p1.add(l2);
p2.setLayout(new GridLayout(4,1));
p2.add(new Label());p2.add(text1);p2.add(text2);
p3.setLayout(new GridLayout(4,2));
p3.add(new Label()); p3.add(new Label());p3.add(b1);p3.add(new Label());p3.add(b2);
p3.add(new Label()); p3.add(new Label()); p3.add(new Label());
add(p1);
add(p2);
add(p3);
b1.addActionListener(this);
b2.addActionListener(this);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
/*System.exit(0);*///ハケヒミオトエーソレケリアユ
}
});
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)//フ晴モ・ナ・
{
String t1,t2;
t1=text1.getText();
t2=text2.getText();
if((t1==null)||(t1.length()==0))
JOptionPane.showMessageDialog(null,"ヌ・菠・ヒコナ!");
else if((t2==null)||(t2.length()==0))
JOptionPane.showMessageDialog(null,"ヌ・菠・ワツ・");
else {
Connection con=null;
Statement st=null;
String sql="";
sql="select User,Psd from Users where User='"+t1+"' and Psd='"+t2+"';";
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//チャスモハセンソ・
con=DriverManager.getConnection("jdbc:odbc:Stu");
st=con.createStatement();
ResultSet rs=st.executeQuery(sql);
if (rs.next())
{
setVisible(false);
new Student("ムァノ昻ナマ「ケワタ榘オヘウ",400,400);
pack();
}
else
JOptionPane.showMessageDialog(null,"モテサァテ釗ワツ・﨔・");
}
catch(Exception e4){
{JOptionPane.showMessageDialog(null,"ウ・");}
}
}
}
else if (e.getSource()==b2)
{
setVisible(false);
System.exit(0);
}
}
}
学生信息管理系统 login.java
最新推荐文章于 2022-04-16 19:46:26 发布