Advertisement
CastelShal

Java Swing+DB

Aug 22nd, 2023
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.11 KB | None | 0 0
  1. package edu;
  2.  
  3. import java.awt.*;
  4. import java.awt.event.*;
  5. import javax.swing.*;
  6. import java.sql.*;
  7. public class Login implements ActionListener {
  8.     JTextField username;
  9.     JPasswordField pass;
  10.     JPanel jp;
  11.     JFrame jeff;
  12.     JLabel l1, l2, l3;
  13.     JButton button;
  14.    
  15.     Login(){
  16.         try {
  17.             Class.forName("org.mariadb.jdbc.Driver");
  18.             Connection cn = DriverManager.getConnection("jdbc:mariadb://localhost:3306/syit","root","mariadb");
  19.         } catch (Exception e) {
  20.             // TODO Auto-generated catch block
  21.             e.printStackTrace();
  22.         }
  23.        
  24.        
  25.         username = new JTextField(20);
  26.         pass = new JPasswordField(20);
  27.         l1 = new JLabel("Username");
  28.         l2 = new JLabel("Password");
  29.         l3 = new JLabel("");
  30.         button = new JButton("Submit");
  31.        
  32.         jp = new JPanel();
  33.         jp = new JPanel(new GridLayout(3, 2, 10, 10));
  34.         jp.add(l1);
  35.         jp.add(username);
  36.         jp.add(l2);
  37.         jp.add(pass);
  38.         jp.add(l3);
  39.         jp.add(button);
  40.        
  41.         jeff = new JFrame();
  42.         jeff.add(jp);
  43.         jeff.pack();
  44.         jeff.setVisible(true);
  45.         }
  46.    
  47.     public void actionPerformed(ActionEvent e) {
  48.        
  49.     }
  50.    
  51.     public static void main(String[] args) {
  52.         new Login();
  53.     }
  54.  
  55. }
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement