Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /*package wholesale;
- import java.awt.*;
- import java.awt.event.*;
- import java.sql.*;
- import javax.swing.AbstractButton;
- import javax.swing.Action;
- import javax.swing.ImageIcon;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JOptionPane;
- import javax.swing.JPasswordField;
- import javax.swing.JTextField;
- import javax.swing.JWindow;
- import javax.swing.Timer;
- import javax.swing.JComboBox;
- public class Wholesale {
- public static void main(String ar[]) throws SQLException
- {
- splash obj =new splash();
- }
- }
- class splash extends JWindow
- {
- public splash() throws SQLException
- {
- getContentPane().setBackground(Color.white);
- setLayout(new BorderLayout());
- JLabel background=new JLabel(new ImageIcon("splash.jpg"));
- Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
- setSize(428,250);
- // Determine the new location of the window
- int w = this.getSize().width;
- int h = this.getSize().height;
- int x = (dim.width-w)/2;
- int y = (dim.height-h)/2;
- // Move the window
- this.setLocation(x, y);
- add(background);
- background.setLayout(new FlowLayout());
- setVisible(true);
- Timer timer = new Timer(10, new MyTimerActionListener());
- timer.start();
- try {
- Thread.sleep(500);
- new login();
- } catch (InterruptedException e) {
- }
- setVisible(false);
- //new login();
- timer.stop();
- }
- //@SuppressWarnings("serial")
- class MyTimerActionListener implements ActionListener
- {
- public void actionPerformed(ActionEvent actionevent)
- {
- }
- }
- }
- class login extends JFrame implements ActionListener,KeyListener
- {
- JButton b1,b;
- JTextField t;
- JPasswordField p1;
- JLabel i,p;
- Connection con;
- Statement stmnt;
- ResultSet rst;
- public login() throws SQLException
- {
- Dimension dime = Toolkit.getDefaultToolkit().getScreenSize();
- // Determine the new location of the window
- int ii = this.getSize().width;
- int c = this.getSize().height;
- int o = (dime.width-ii)/4;
- int n = (dime.height-c)/4;
- getContentPane().setBackground(Color.white);
- setLayout(new BorderLayout());
- JLabel background=new JLabel(new ImageIcon("icon.jpg"));
- try{
- //con=DriverManager.getConnection("jdbc:ucanaccess://rentcar.accdb");
- }
- catch(Exception e)
- {
- //System.out.print(e);
- }
- setLayout(null);
- i=new JLabel("Enter Username");
- i.setBounds(150,55,100,20);
- t=new JTextField();
- t.setBounds(250,55,170,20);
- p=new JLabel("Enter Password");
- p.setBounds(150,95,100,20);
- p1=new JPasswordField();
- p1.setBounds(250,95,170,20);
- p1.addKeyListener(this);
- b =new JButton ("Login");
- b.setBounds(250,145,70,26);
- b1 =new JButton ("Cancel");
- b1.setBounds(335,145,85,26);
- background.setBounds(0, 0, 143, 201);
- add(background);
- add(i);
- add(b1);
- add(p);
- add(t);
- add(p1);
- add(b);
- setSize(458,240);
- Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
- // Determine the new location of the window
- int w = this.getSize().width;
- int h = this.getSize().height;
- int x = (dim.width-w)/2;
- int y = (dim.height-h)/2;
- this.setLocation(x, y);
- setVisible(true);
- b1.addActionListener(this);
- b.addActionListener(this);
- }
- public void actionPerformed(ActionEvent e)
- {
- if(e.getSource()==b1)
- {
- System.exit(0);
- setVisible(false);
- }
- if(e.getSource()==b)
- {
- try
- {
- //stmnt=con.createStatement();
- //rst=stmnt.executeQuery("Select * from u_login where username='" + t.getText() + "' and password='" + p1.getText().toString() + "'");
- if(rst.next())
- {
- setVisible(false);
- //new carmain();
- }
- else
- {
- JOptionPane.showMessageDialog(null, "Invalid Username / Password");
- }
- }
- catch(Exception e2){
- System.out.println(e2);
- }
- }
- }
- public void keyPressed(KeyEvent a)
- {
- if(a.getSource()==p1)
- {
- if(a.getKeyCode()==10)
- {
- try
- {
- stmnt=con.createStatement();
- rst=stmnt.executeQuery("Select * from u_login where username='" + t.getText() + "' and password='" + p1.getText().toString() + "'");
- if(rst.next())
- {
- setVisible(false);
- new carmain();
- }
- else
- {
- JOptionPane.showMessageDialog(null, "Invalid Username / Password");
- }
- }
- catch(Exception e2){
- System.out.println(e2);
- }
- }
- else
- {
- //JOptionPane.showMessageDialog(null,"bye");
- }
- }
- }
- public void keyReleased(KeyEvent a) {
- }
- public void keyTyped(KeyEvent a) {
- }
- }
- */
Add Comment
Please, Sign In to add comment