NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

package Project;

import java.awt.EventQueue;
import java.awt.Canvas;
import java.awt.Choice;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JPasswordField;
import javax.swing.SwingConstants;
import javax.swing.JProgressBar;
import javax.swing.ImageIcon;
import javax.swing.JRadioButton;

import java.sql.*;

public class userLogin {

JFrame frame;
private JTextField user_name;
private JPasswordField pass;

/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
userLogin window = new userLogin();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Create the application.
*/
public userLogin() {
initialize();
}

/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.getContentPane().setBackground(new Color(230, 230, 250));
frame.getContentPane().setLayout(null);

JLabel lblUsername = new JLabel("Username");
lblUsername.setFont(new Font("Segoe UI Symbol", Font.BOLD, 15));
lblUsername.setBounds(65, 113, 110, 42);
frame.getContentPane().add(lblUsername);

user_name = new JTextField();
user_name.setFont(new Font("Segoe UI Symbol", Font.PLAIN, 15));
user_name.setColumns(10);
user_name.setBounds(89, 158, 166, 32);
frame.getContentPane().add(user_name);

JButton btnLogIn = new JButton("Log In");
btnLogIn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String userName = user_name.getText();
String password = pass.getText();
int is_Admin=0;
try {
Connection connection = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/BookShop_DB","root", "leoronaldo29");

PreparedStatement st = (PreparedStatement) connection.prepareStatement("Select user_name, pass, isadmin from account where user_name=? and pass=? and isadmin=?");

st.setString(1, userName);
st.setString(2, password);
st.setInt(3, is_Admin);
//ktu duhet te shtojme si me marr llojin e userit qe pastaj te vendosim me hap admin home ose user home

ResultSet rs = st.executeQuery();
if (rs.next()) {
JOptionPane.showMessageDialog(btnLogIn, "You have successfully logged in");
System.out.println(rs.getInt("isadmin"));
if(rs.getInt("isadmin")==0) {
dispose();
userHome userH = new userHome();
userH.setTitle("User-Home");
userH.frame.setVisible(true);
}
else {
dispose();
adminHome adminH = new adminHome();
adminH.setTitle("Admin-Home");
adminH.frame.setVisible(true);
}
}
else {
JOptionPane.showMessageDialog(btnLogIn, "Wrong Username or Password");
}
}
catch (SQLException sqlException) {
sqlException.printStackTrace();
}
}
});
btnLogIn.setForeground(Color.WHITE);
btnLogIn.setBackground(new Color(153, 153, 204));
btnLogIn.setBounds(75, 297, 80, 32);
frame.getContentPane().add(btnLogIn);

JButton btnRegister = new JButton("Sign Up");
btnRegister.setForeground(Color.WHITE);
btnRegister.setBackground(new Color(153, 153, 204));
btnRegister.setBounds(167, 297, 88, 32);
frame.getContentPane().add(btnRegister);
btnRegister.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dispose();
register userRegister = new register();
userRegister.setTitle("User-Register");
userRegister.frame.setVisible(true);
}
});
JLabel lblPassword = new JLabel("Password");
lblPassword.setFont(new Font("Segoe UI Symbol", Font.BOLD, 15));
lblPassword.setBounds(65, 191, 110, 42);
frame.getContentPane().add(lblPassword);

pass = new JPasswordField();
pass.setBounds(89, 237, 166, 32);
frame.getContentPane().add(pass);

JLabel lblNewLabel = new JLabel("BOOKSHOP");
lblNewLabel.setLabelFor(frame);
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel.setFont(new Font("Segoe UI Semibold", Font.BOLD, 23));
lblNewLabel.setBounds(65, 49, 203, 63);
frame.getContentPane().add(lblNewLabel);
frame.setBackground(Color.RED);
frame.setBounds(100, 100, 339, 438);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

protected void dispose() {
// TODO Auto-generated method stub

}

public void setTitle(String string) {
// TODO Auto-generated method stub

}
}
     
 
what is notes.io
 

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

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.