Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.*;
- import java.util.HashMap;
- import java.util.Map;
- class GUIBank extends JFrame{
- private JFrame LoginCard, LoginAdmin, LoginUser, CreateAccount,BankTransaction;
- private JPanel WelcomePage, WelcomeAdmin, WelcomeUser, CreateAccountP, Transaction;
- private JButton admin, user, admin_login, user_login, withdraw, deposit, transfer, create ;
- private JTextField AccessName, AccessPassword, AdminName, AdminPassword, UserID, UserPassword,
- WithdrawAmount, DepositAmount, TransferAmountfrom, TransferAmountto,AccNo, NewUserName, NewUserID, NewUserType;
- private JLabel enterAccessName,enterAccessPassword,enterAdminName,enterAdminPassword,enterUserName,
- enterUserPassword,enterNewUserID, enterNewUserType, enterNewUserName,enterUserID, enterWithdraw, enterDeposit, entersource,
- enterdestination;
- /*private JLabel lab;*/
- public GUIBank()
- {
- Bank_Welcome_Page();
- //Admin_Welcome_Page();
- //User_Welcome_Page();
- //Create_Account();
- //Bank_Transaction();
- }
- public void Bank_Welcome_Page()
- {
- LoginCard= new JFrame(" Welcome to the Bank!");
- LoginCard.setSize(500,500);
- LoginCard.setLayout(new GridLayout(6, 6));
- LoginCard.setVisible(true);
- LoginCard.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- LoginCard.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent windowEvent){
- //System.exit(0);
- //swingControlDemo.prepareGUI();
- }
- });
- final Map<String, String> unamepass;
- unamepass = new HashMap<String, String>();
- /*
- * Only two user exists ,
- */
- unamepass.put("ritu", "abc");
- unamepass.put("kitu", "xyz");
- WelcomePage = new JPanel();
- WelcomePage.setLayout(new FlowLayout());
- LoginCard.setBackground(Color.RED);
- admin = new JButton("Admin");
- admin.setSize(10, 10);
- user = new JButton("User");
- user.setSize(10,10);
- enterAccessName= new JLabel("Enter Access Name",JLabel.RIGHT);
- enterAccessName.setSize(300,200);
- AccessName = new JTextField(10);
- AccessName.setSize(10,50);
- //AccessName.setAlignmentY(0);
- enterAccessPassword = new JLabel("Enter Password",JLabel.RIGHT);
- AccessPassword = new JTextField(10);
- /*lab = new JLabel("This is test Label");*/
- LoginCard.add(WelcomePage);
- WelcomePage.add(enterAccessName);
- WelcomePage.add(AccessName);
- WelcomePage.add(enterAccessPassword);
- WelcomePage.add(AccessPassword);
- WelcomePage.add(admin);
- WelcomePage.add(user);
- admin.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- String uname = adduname.getText();
- String pass = addpass.getText();
- String mychoice = choice.getText();
- String data = "";
- if ( unamepass.containsKey(uname)) {
- //System.out.println(uname+pass);
- String val = unamepass.get(uname);
- if (val.equals(pass)) {
- flag = 1;
- } else {
- System.out.println("username password does not match, close window");
- flag = 0;
- }
- }
- if ( flag == 1) {
- System.out.println("username password matches, close window");
- if (mychoice.equals("R"))
- flag = 2;
- if (mychoice.equals("A"))
- flag = 3;
- }
- }
- });
- user.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- String uname = adduname.getText();
- String pass = addpass.getText();
- String mychoice = choice.getText();
- String data = "";
- if ( unamepass.containsKey(uname)) {
- //System.out.println(uname+pass);
- String val = unamepass.get(uname);
- if (val.equals(pass)) {
- flag = 1;
- } else {
- System.out.println("username password does not match, close window");
- flag = 0;
- }
- }
- if ( flag == 1) {
- System.out.println("username password matches, close window");
- if (mychoice.equals("R"))
- flag = 2;
- if (mychoice.equals("A"))
- flag = 3;
- }
- }
- });
- //LoginCard.add(WelcomePage);
- LoginCard.setVisible(true);
- }
- public void Admin_Welcome_Page()
- {
- LoginAdmin= new JFrame(" Welcome Admin!");
- LoginAdmin.setSize(500,500);
- LoginAdmin.setLayout(new GridLayout(6, 6));
- LoginAdmin.setVisible(true);
- LoginAdmin.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- WelcomeAdmin = new JPanel();
- WelcomeAdmin.setLayout(new FlowLayout());
- LoginAdmin.setBackground(Color.RED);
- admin_login = new JButton("Login");
- admin_login.setSize(10, 10);
- enterAdminName= new JLabel("Enter Admin Name",JLabel.RIGHT);
- enterAdminName.setSize(300,200);
- AdminName = new JTextField(10);
- AdminName.setSize(10,50);
- //AccessName.setAlignmentY(0);
- enterAdminPassword= new JLabel("Enter Password",JLabel.RIGHT);
- enterAdminPassword.setSize(300,200);
- AdminPassword = new JTextField(10);
- AdminPassword.setSize(10,50);
- /*admin.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e){
- }
- });
- /*lab = new JLabel("This is test Label");*/
- LoginAdmin.add(WelcomeAdmin);
- WelcomeAdmin.add(enterAdminName);
- WelcomeAdmin.add(AdminName);
- WelcomeAdmin.add(enterAdminPassword);
- WelcomeAdmin.add(AdminPassword);
- WelcomeAdmin.add(admin_login);
- //LoginCard.add(WelcomePage);
- LoginAdmin.setVisible(true);
- }
- public void User_Welcome_Page()
- {
- LoginUser= new JFrame(" Welcome User!");
- LoginUser.setSize(500,500);
- LoginUser.setLayout(new GridLayout(6, 6));
- LoginUser.setVisible(true);
- LoginUser.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- WelcomeUser = new JPanel();
- WelcomeUser.setLayout(new FlowLayout());
- LoginUser.setBackground(Color.RED);
- user_login = new JButton("Login");
- user_login.setSize(10, 10);
- enterUserName= new JLabel("Enter User ID",JLabel.RIGHT);
- enterUserName.setSize(300,200);
- UserID = new JTextField(10);
- UserID.setSize(10,50);
- //AccessName.setAlignmentY(0);
- enterUserPassword= new JLabel("Enter Password",JLabel.RIGHT);
- enterUserPassword.setSize(300,200);
- UserPassword = new JTextField(10);
- UserPassword.setSize(10,50);
- /*admin.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e){
- }
- });
- /*lab = new JLabel("This is test Label");*/
- LoginUser.add(WelcomeUser);
- WelcomeUser.add(enterUserName);
- WelcomeUser.add(UserID);
- WelcomeUser.add(enterUserPassword);
- WelcomeUser.add(UserPassword);
- WelcomeUser.add(user_login);
- //LoginCard.add(WelcomePage);
- LoginUser.setVisible(true);
- }
- public void Create_Account()
- {
- CreateAccount= new JFrame(" Create Account Holder");
- CreateAccount.setSize(500,500);
- CreateAccount.setLayout(new GridLayout(6, 6));
- CreateAccount.setVisible(true);
- CreateAccount.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- CreateAccountP = new JPanel();
- CreateAccountP.setLayout(new FlowLayout());
- CreateAccount.setBackground(Color.RED);
- create = new JButton("Create Account");
- create.setSize(10, 10);
- enterNewUserName= new JLabel("Enter New User Name",JLabel.RIGHT);
- enterNewUserName.setSize(300,200);
- enterNewUserID= new JLabel("Enter New User ID",JLabel.RIGHT);
- enterNewUserID.setSize(300,200);
- enterNewUserType= new JLabel("Enter New User Type Checkin/Savings",JLabel.RIGHT);
- enterNewUserType.setSize(300,200);
- NewUserName = new JTextField(10);
- NewUserName.setSize(10,50);
- NewUserID = new JTextField(10);
- NewUserID.setSize(10,50);
- NewUserType = new JTextField(10);
- NewUserType.setSize(10,50);
- //AccessName.setAlignmentY(0);
- /*admin.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e){
- }
- });
- /*lab = new JLabel("This is test Label");*/
- CreateAccount.add(CreateAccountP);
- CreateAccountP.add(enterNewUserName);
- CreateAccountP.add(NewUserName);
- CreateAccountP.add(enterNewUserID);
- CreateAccountP.add(NewUserID);
- CreateAccountP.add(enterNewUserType);
- CreateAccountP.add(NewUserType);
- CreateAccountP.add(create);
- //LoginCard.add(WelcomePage);
- CreateAccount.setVisible(true);
- }
- public void Bank_Transaction()
- {
- BankTransaction= new JFrame(" Create Account Holder");
- BankTransaction.setSize(600,600);
- BankTransaction.setLayout(new GridLayout(6, 6,5,5));
- BankTransaction.setVisible(true);
- BankTransaction.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- Transaction = new JPanel();
- Transaction.setLayout(new FlowLayout());
- BankTransaction.setBackground(Color.RED);
- withdraw = new JButton("Withdraw");
- withdraw.setSize(10, 10);
- //withdraw.add(Box.createHorizontalStrut(10));
- deposit = new JButton("Deposit");
- deposit.setSize(10, 10);
- //deposit.add(Box.createHorizontalStrut(10));
- transfer = new JButton("Transfer");
- transfer.setSize(10, 10);
- enterUserID= new JLabel("Enter User ID",JLabel.RIGHT);
- enterUserID.setSize(300,200);
- enterUserID.add(Box.createHorizontalStrut(60));
- enterWithdraw= new JLabel("Enter amount to be Withdrawn");
- enterWithdraw.setSize(300,200);
- enterDeposit= new JLabel("Enter amount to be deposited");
- enterDeposit.setSize(300,200);
- entersource= new JLabel("Savings/Checkin",JLabel.RIGHT);
- entersource.setSize(300,200);
- enterdestination= new JLabel("Savings/Checkin",JLabel.RIGHT);
- enterdestination.setSize(300,200);
- AccNo = new JTextField(10);
- AccNo.setSize(10,50);
- WithdrawAmount = new JTextField(10);
- WithdrawAmount.setSize(10,50);
- DepositAmount = new JTextField(10);
- DepositAmount.setSize(10,50);
- TransferAmountfrom = new JTextField(10);
- TransferAmountfrom.setSize(10,50);
- TransferAmountto = new JTextField(10);
- TransferAmountto.setSize(10,50);
- //AccessName.setAlignmentY(0);
- /*admin.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e){
- }
- });
- /*lab = new JLabel("This is test Label");*/
- BankTransaction.add(Transaction);
- Transaction.add(enterUserID);
- Transaction.add(AccNo);
- Transaction.add(enterWithdraw);
- Transaction.add(WithdrawAmount);
- Transaction.add(withdraw);
- Transaction.add(enterDeposit);
- Transaction.add(DepositAmount);
- Transaction.add(deposit);
- Transaction.add(entersource);
- Transaction.add(TransferAmountfrom);
- Transaction.add(enterdestination);
- Transaction.add(TransferAmountto);
- Transaction.add(transfer);
- //LoginCard.add(WelcomePage);
- BankTransaction.setVisible(true);
- }
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- new GUIBank();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement