Notes
Notes - notes.io |
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.*;
import java.sql.DriverManager;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;
public class LoginPage extends JFrame{
private JPanel contentPane;
private JTextField user;
private JPasswordField pass;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
LoginPage frame = new LoginPage();
frame.setVisible(true);
}catch(Exception e){
e.printStackTrace();
}
}
});
}
public LoginPage() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100,100,234,280);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5,5,5,5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lblLoginPage = new JLabel("Login Page");
lblLoginPage.setHorizontalAlignment(SwingConstants.CENTER);
lblLoginPage.setFont
(new Font("Times New Roman", Font.PLAIN, 26));
lblLoginPage.setBounds(10,11,198,42);
contentPane.add(lblLoginPage);
JLabel lblUsername = new JLabel("Username");
lblUsername.setBounds(20,64,62,14);
contentPane.add(lblUsername);
user = new JTextField();
user.setBounds(20,78,198,28);
contentPane.add(user);
user.setColumns(10);
JLabel lblPassword = new JLabel("Password");
lblPassword.setBounds(20,117,62,14);
contentPane.add(lblPassword);
pass = new JPasswordField();
pass.setBounds(10,132,198,28);
contentPane.add(pass);
JButton btnLogin = new JButton("Login");
btnLogin.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection con = DriverManager.getConnection
("jdbc:mysql://localhost:3306/cs3a","root","");
Statement stmt = con.createStatement();
String sql = "SELECT * FROM users WHERE username="
+ "'"+user.getText()+"' AND password='"+pass.getText().toString()+"'";
ResultSet rs = stmt.executeQuery(sql);
if(rs.next()) {
JOptionPane.showMessageDialog(null, "Login Successfully");
MainPage mp = new MainPage(user.getText());
}else {
JOptionPane.showMessageDialog(null, "Login failed Successfully");
}
}catch(Exception ex) {System.out.print(ex);}
}
});
btnLogin.setBounds(10,171,89,23);
contentPane.add(btnLogin);
JButton rgBtn = new JButton("Register");
rgBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Register rg = new Register();
}
});
rgBtn.setBounds(110,171,89,23);
contentPane.add(rgBtn);
}
}
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team