Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Login_Sys;
- import java.awt.EventQueue;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JOptionPane;
- import javax.swing.JPasswordField;
- import javax.swing.JTextField;
- //Change to package you want after login Success//
- import test.test;
- import javax.swing.JButton;
- import javax.swing.JSeparator;
- import java.awt.Color;
- import java.awt.event.ActionListener;
- import java.awt.event.ActionEvent;
- import java.awt.Font;
- public class Login_S {
- private JFrame frame;
- private JPasswordField txtPassword;
- private JTextField txtUsername;
- /**
- * Launch the application.
- */
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- Login_S window = new Login_S();
- window.frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * Create the application.
- */
- public Login_S() {
- initialize();
- }
- /**
- * Initialize the contents of the frame.
- */
- private void initialize() {
- frame = new JFrame();
- frame.getContentPane().setBackground(Color.DARK_GRAY);
- frame.setBounds(200, 200, 500, 300);
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.getContentPane().setLayout(null);
- JLabel lblNewLabel = new JLabel("Login");
- lblNewLabel.setForeground(Color.WHITE);
- lblNewLabel.setFont(new Font("Dialog", Font.BOLD, 25));
- lblNewLabel.setBounds(195, 12, 161, 32);
- frame.getContentPane().add(lblNewLabel);
- JLabel lblNewLabel_1 = new JLabel("Username");
- lblNewLabel_1.setForeground(Color.WHITE);
- lblNewLabel_1.setFont(new Font("Dialog", Font.BOLD, 17));
- lblNewLabel_1.setBounds(58, 87, 109, 15);
- frame.getContentPane().add(lblNewLabel_1);
- JLabel lblNewLabel_2 = new JLabel("Password");
- lblNewLabel_2.setForeground(Color.WHITE);
- lblNewLabel_2.setFont(new Font("Dialog", Font.BOLD, 17));
- lblNewLabel_2.setBounds(58, 156, 109, 15);
- frame.getContentPane().add(lblNewLabel_2);
- txtPassword = new JPasswordField();
- txtPassword.setBounds(185, 154, 124, 19);
- frame.getContentPane().add(txtPassword);
- txtUsername = new JTextField();
- txtUsername.setBounds(185, 85, 124, 19);
- frame.getContentPane().add(txtUsername);
- txtUsername.setColumns(10);
- JButton btnLogin = new JButton("Login");
- btnLogin.setForeground(Color.GREEN);
- btnLogin.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e)
- {
- String password = txtPassword.getText();
- String username = txtUsername.getText();
- //Teste das pass //
- if (password.contains("test") && username.contains("test")) {
- txtPassword.setText(null);
- txtUsername.setText(null);
- test info = new test();
- test.main(null);
- }
- else
- {
- JOptionPane.showMessageDialog(null, "Ah Ah Ah Du hast das Zauberwort nicht gesagt!!!","Zugriff Verweigert", 0);
- txtPassword.setText(null);
- txtUsername.setText(null);
- }
- }
- });
- btnLogin.setBounds(53, 218, 114, 25);
- frame.getContentPane().add(btnLogin);
- JButton btnReset = new JButton("Reset");
- btnReset.setForeground(Color.ORANGE);
- btnReset.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- txtUsername.setText(null);
- txtPassword.setText(null);
- }
- });
- btnReset.setBounds(195, 218, 114, 25);
- frame.getContentPane().add(btnReset);
- JButton btnExit = new JButton("Exit");
- btnExit.setForeground(Color.RED);
- btnExit.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- JFrame frmLoginSystem = new JFrame("Exit");
- if (JOptionPane.showConfirmDialog(frmLoginSystem, "Confirm Exit", "Login System",
- JOptionPane.YES_NO_OPTION)== JOptionPane.YES_NO_OPTION) {
- System.exit(0);
- }
- }
- });
- btnExit.setBounds(336, 218, 114, 25);
- frame.getContentPane().add(btnExit);
- JSeparator separator = new JSeparator();
- separator.setForeground(Color.BLACK);
- separator.setBackground(Color.BLACK);
- separator.setBounds(0, 202, 488, 2);
- frame.getContentPane().add(separator);
- JSeparator separator_1 = new JSeparator();
- separator_1.setForeground(Color.BLACK);
- separator_1.setBackground(Color.BLACK);
- separator_1.setBounds(0, 51, 511, 2);
- frame.getContentPane().add(separator_1);
- }
- }
Add Comment
Please, Sign In to add comment