欢迎来到天天文库
浏览记录
ID:38791664
大小:27.43 KB
页数:28页
时间:2019-06-19
《景点售票系统源代码》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、importjava.awt.Dimension;importjava.awt.GridLayout;importjava.awt.Toolkit;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.sql.Statement;importj
2、avax.swing.JButton;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JOptionPane;importjavax.swing.JPanel;importjavax.swing.JPasswordField;importjavax.swing.JTextField;publicclassLogOn{publicstaticvoidmain(String[]args)throwsSQLException{finalJFramejfrmlogin=newJFr
3、ame("系统登录");jfrmlogin.setSize(400,280);DimensionscreenSize=Toolkit.getDefaultToolkit().getScreenSize();jfrmlogin.setLocation((int)(screenSize.width-400)/2,(int)(screenSize.height-300)/2);//设置框出现的位置JPanelp1=newJPanel();p1.add(newJLabel("用户名:"));finalJTextFieldjtxtuser=newJTextField(1
4、4);JPanelp2=newJPanel();p2.add(newJLabel("密码:"));finalJPasswordFieldjspwd=newJPasswordField(14);JPanelp3=newJPanel();finalJButtonjbtUser=newJButton("登录");finalJButtonjbtreg=newJButton("注册");JButtonjbtexit=newJButton("退出");p1.add(jtxtuser);p2.add(jspwd);p3.add(jbtUser);p3.add(jbtreg)
5、;p3.add(jbtexit);jbtUser.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){Connectionconn=null;ResultSetrs=null;Statementstmt=null;if(e.getSource()==jbtUser){try{Class.forName("oracle.jdbc.driver.OracleDriver");conn=DriverManager.getConnection("jdbc:oracl
6、e:thin:@localhost:1521:orcl","system","123");stmt=conn.createStatement();StringUSER_NAME=jtxtuser.getText();rs=stmt.executeQuery("select*fromTICKET_USERSwhereUSER_NAME='"+jtxtuser.getText()+"'andUSER_PWD='"+jspwd.getText()+"'");if(rs.next()){if(USER_NAME.equals("admin")==false){Main
7、Usermf=newMainUser();mf.setVisible(true);jfrmlogin.dispose();}else{MainFramemf=newMainFrame();mf.setVisible(true);jfrmlogin.dispose();}}else{JOptionPane.showMessageDialog(null,"用户名或密码不一致,请重新输入!","系统提示",JOptionPane.ERROR_MESSAGE);jtxtuser.setText("");jspwd.setText("");}}catch(Excepti
8、onex){JOptionPane.s
此文档下载收益归作者所有