【Java开源代码栏目提醒】:网学会员为广大网友收集整理了,admin_frm.java,希望对大家有所帮助!
package train_table;
import java.awt.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.border.*;
public class admin_frm extends JFrame {
private JLabel jLabel1 = new JLabel();
private JLabel jLabel2 = new JLabel();
private JButton jButton1 = new JButton();
private JButton jButton2 = new JButton();
private XYLayout xYLayout1 = new XYLayout();
private JPanel jPanel1 = new JPanel();
private XYLayout xYLayout2 = new XYLayout();
private Border border1;
private JPanel jPanel2 = new JPanel();
private XYLayout xYLayout3 = new XYLayout();
private Border border2;
private JPanel jPanel3 = new JPanel();
private Border border3;
private XYLayout xYLayout4 = new XYLayout();
private JLabel jLabel3 = new JLabel();
private JPasswordField password_txt = new JPasswordField();
private JTextField usertxt = new JTextField();
public admin_frm() {
try {
jbInit();
this.setTitle("北京西客站票务系统");
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
border1 = BorderFactory.createEmptyBorder();
border2 = BorderFactory.createLineBorder(SystemColor.activeCaption,1);
border3 = BorderFactory.createLineBorder(SystemColor.activeCaption,1);
jLabel1.setText("管理员 :");
this.getContentPane().setLayout(xYLayout1);
jLabel2.setText("密 码 :");
jButton1.setText("确定");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton1_actionPerformed(e);
}
});
jButton2.setText("退出");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton2_actionPerformed(e);
}
});
jPanel1.setLayout(xYLayout2);
jPanel1.setBorder(border1);
jPanel2.setLayout(xYLayout3);
jPanel2.setBorder(border2);
jPanel3.setBorder(border3);
jPanel3.setLayout(xYLayout4);
xYLayout1.setWidth(400);
xYLayout1.setHeight(174);
jLabel3.setForeground(Color.red);
jLabel3.setText("联系我们>>>");
jLabel3.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseExited(MouseEvent e) {
jLabel3_mouseExited(e);
}
public void mouseClicked(MouseEvent e) {
jLabel3_mouseClicked(e);
}
});
jLabel3.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
public void mouseMoved(MouseEvent e) {
jLabel3_mouseMoved(e);
}
});
usertxt.setText("zheng");
jPanel2.add(jLabel2, new XYConstraints(103, 63, -1, -1));
jPanel2.add(jLabel1, new XYConstraints(103, 33, -1, -1));
jPanel2.add(password_txt, new XYConstraints(167, 63, 77, 23));
jPanel2.add(usertxt, new XYConstraints(167, 32, 77, 23));
jPanel1.add(jPanel3, new XYConstraints(2, 98, 388, 71));
jPanel3.add(jButton2, new XYConstraints(174, 7, -1, -1));
jPanel3.add(jButton1, new XYConstraints(115, 7, -1, -1));
jPanel3.add(jLabel3, new XYConstraints(305, 40, -1, -1));
jPanel1.add(jPanel2, new XYConstraints(2, 0, 388, 100));
this.getContentPane().add(jPanel1, new XYConstraints(4, 2, 390, 296));
pack();
}
void jButton1_actionPerformed(ActionEvent e) {
errormessage errmsg=new errormessage(); //错误处理
ResultSet rs=null; //定义结果集rs,存放结果集
dbBean db=new dbBean(); //实例化dbBean用于查询
String user=usertxt.getText();
String password=password_txt.getText();
//sql查询语句,用于核查用户和密码
String sql="select * from administartor where admini='"+user+"' and password='"+password+"'";
//检查输入是否为空
if(!errmsg.isEmpty(user)&&!errmsg.isEmpty(password))
{
try{
rs=db.executeQuery(sql); //执行查询
if(rs.next()) //判断结果集是否存在
{
GetFrmLocation gfl=ne