login's Introduction
login's People
login's Issues
login.java
package GUI1;
import java.awt.BorderLayout;
import java.awt.Event;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.awt.Font;
import javax.swing.SwingConstants;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.lang.invoke.TypeDescriptor.OfField;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Scanner;
import java.awt.event.ActionEvent;
import java.awt.event.KeyAdapter;
public class login extends JFrame {
private JPanel contentPane;
private JTextField tfuser;
private JTextField tfpass;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
login frame = new login();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public login() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 318);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lblNewLabel = new JLabel("\u0110\u0103ng Nh\u1EADp H\u1EC7 Th\u1ED1ng");
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 30));
lblNewLabel.setBounds(76, 10, 333, 33);
contentPane.add(lblNewLabel);
JLabel lblUser = new JLabel("T\u00E0i Kho\u1EA3n");
lblUser.setFont(new Font("Tahoma", Font.PLAIN, 20));
lblUser.setBounds(20, 82, 106, 33);
contentPane.add(lblUser);
tfuser = new JTextField();
tfuser.setBounds(150, 85, 173, 30);
contentPane.add(tfuser);
tfuser.setColumns(10);
JLabel lblPassword = new JLabel("M\u1EADt Kh\u1EA9u");
lblPassword.setFont(new Font("Tahoma", Font.PLAIN, 20));
lblPassword.setBounds(26, 157, 125, 38);
contentPane.add(lblPassword);
JButton btnLogin = new JButton("\u0110\u0103ng Nh\u1EADp");
btnLogin.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
java.sql.Connection conn = null;
try {
String dbURL = "jdbc:sqlserver://ADMIN\\SQLEXPRESS:1433;databaseName=CSDLVSJAVA;user=sa;password=123456";
conn = DriverManager.getConnection(dbURL);
java.sql.Statement s = conn.createStatement();
ResultSet rs = s.executeQuery("Select [user] ,[pass] from [CSDLVSJAVA].[dbo].[login] where [login].[user]='"+tfuser.getText()+"' and [login].[pass]='"+tfpass.getText()+"'");
if(rs.next()) {
JOptionPane.showMessageDialog(null, "Dang Nhap Thanh Cong");
}
else {
JOptionPane.showMessageDialog(null, "Dang Nhap That Bai");
}
}catch(Exception e2) {
e2.printStackTrace();
}
}
});
btnLogin.setFont(new Font("Tahoma", Font.PLAIN, 13));
btnLogin.setBounds(178, 225, 106, 33);
contentPane.add(btnLogin);
tfpass = new JTextField();
tfpass.setBounds(150, 157, 173, 33);
contentPane.add(tfpass);
tfpass.setColumns(10);
}
}
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.