Advertisement
Guest User

Untitled

a guest
Jun 11th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 11.11 KB | None | 0 0
  1. import javax.swing.*;
  2.  
  3. import java.awt.*;
  4. import java.awt.event.*;
  5. import java.io.PrintStream;
  6. import java.util.Arrays;
  7. import java.net.*;
  8. import java.util.*;
  9.  
  10.  
  11.  
  12.  
  13.  
  14. public class login extends JFrame {
  15.     /**
  16.      *
  17.      */
  18.     private static final long serialVersionUID = 1L;
  19.     static JFrame passFrame = new JFrame("Login");
  20.     static JTextField username = new JTextField(10);
  21.     static JPasswordField passEntry = new JPasswordField(10);
  22.     static JFrame menuFrame = new JFrame("CyberSafe Menu");
  23.     static JTextField moneyInput = new JTextField(10);
  24.     static JButton withdrawButton = new JButton("Withdraw");
  25.     static int x;
  26.     static JFrame Withdrawls = new JFrame("Withdrawls");
  27.     static JLabel work = new JLabel("You have: " +(x)+" dollars.");
  28.    
  29.    
  30.     public static void main(String[] arguments) {
  31.        
  32.    
  33.        
  34.         JFrame loginFrame = new JFrame("Login");
  35.         loginFrame.setSize(1235, 90);
  36.         FlowLayout flo = new FlowLayout();
  37.  
  38.         JLabel pageLabel = new JLabel("Welcome to CyberSafe. Please Login!");
  39.  
  40.         //Toolkit.getDefaultToolkit().beep();
  41.  
  42.  
  43.         //TextField password1 = new TextField(8);
  44.         //password1.setEchoChar('*');
  45.         JButton submit = new JButton("Login!");
  46.  
  47.  
  48.  
  49.         loginFrame.add(pageLabel);
  50.         loginFrame.add(submit);
  51.         loginFrame.setLayout(flo);
  52.  
  53.         submit.addActionListener(new  Login());
  54.         loginFrame.setVisible(true);
  55.     }
  56.  
  57.  
  58.  
  59.     public login() {
  60.        
  61.  
  62.  
  63.  
  64.         JFrame pics = new JFrame("Pictures");
  65.         pics.setSize(400, 400);
  66.         pics.setSize(500, 500);
  67.         pics.setSize(501, 501);
  68.         JPanel pane = new JPanel();
  69.         JButton next = new JButton("Next ----->");
  70.  
  71.         ImageIcon pic1 = new ImageIcon("/Users/amazingmiki/Desktop/pic/gol-de-Forlan.jpg");
  72.         JLabel pic2 = new JLabel(pic1);
  73.         next.addActionListener(new  next());
  74.  
  75.         pics.setVisible(true);
  76.         pane.add(next);
  77.         pane.add(pic2);
  78.         pics.add(pane);
  79.  
  80.         //TextField
  81.         //JTextField pageAddress = new JTextField(20);
  82.         //Buttons
  83.         //JButton go = new JButton ("GO!");
  84.  
  85.         //Checkboxes
  86.         //JCheckBox jumboSize = new JCheckBox("Jumbo Size!");
  87.         //JComboBox profession = new JComboBox();
  88.         //TextAreas! With Scroll Bars!
  89.         //JPanel row3 = new JPanel();
  90.         //JLabel messageLabel = new JLabel("Message: ");
  91.         //row3.add(messageLabel);
  92.         //JTextArea message = new JTextArea(4, 22);
  93.         //message.setLineWrap(true);
  94.         //message.setWrapStyleWord(true);
  95.         //JScrollPane scroll = new JScrollPane(message,
  96.         //JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
  97.         //JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
  98.         //row3.add(scroll);
  99.         //Sliders!
  100.         //JSlider guess = new JSlider(JSlider.VERTICAL, 1, 1000, 500);
  101.         //ImageIcons!
  102.         //ImageIcon stopSign = new ImageIcon("stopsign.gif");
  103.         //PasswordFields
  104.         //JTextField password1 = new JTextField(8);
  105.  
  106.  
  107.  
  108.         //FlowLayout is needed!
  109.         FlowLayout flo = new FlowLayout();
  110.         //Items for checkboxes
  111.         // profession.addItem("Butcher");
  112.         //profession.addItem("Computer Scientist");
  113.         //to set CheckBox to editable (User input)
  114.         //profession.setEditable(true);
  115.         setLayout(flo);
  116.         //add items to applet!
  117.  
  118.         // add(pageAddress);
  119.         //add(go);
  120.         //add(jumboSize);
  121.         //add(profession);
  122.         //add(row3);
  123.         // add(guess);
  124.  
  125.  
  126.         pics.setSize(500,400);
  127.  
  128.         //Visible
  129.         setVisible(true);
  130.         //do action of button submit
  131.  
  132.  
  133.  
  134.     }
  135.  
  136.     static class next implements ActionListener{
  137.         public final void actionPerformed(ActionEvent e){
  138.             JFrame nxtPic = new JFrame("Pictures");
  139.             nxtPic.setSize(400, 400);
  140.             nxtPic.setSize(500, 500);
  141.  
  142.             JPanel pane = new JPanel();
  143.             ImageIcon pic1 = new ImageIcon("/Users/amazingmiki/Desktop/pic/Uruguay-vs-Ghana-013.jpg");
  144.             JLabel pic2 = new JLabel(pic1);
  145.  
  146.  
  147.             nxtPic.setVisible(true);
  148.  
  149.             pane.add(pic2);
  150.             nxtPic.add(pane);
  151.             nxtPic.setSize(501, 501);
  152.         }
  153.     }
  154.  
  155.  
  156.     //Sign out
  157.     static class SIGNOUT implements ActionListener{
  158.  
  159.         public final void actionPerformed(ActionEvent e) {
  160.             String ans;
  161.  
  162.             ans = JOptionPane.showInputDialog(null, "Are you sure you want to sign out?");
  163.             if (ans.equalsIgnoreCase("Yes") || (ans.equalsIgnoreCase("y"))){
  164.                 JOptionPane.showMessageDialog(null, "Now closing... Please press OK.", "Status", JOptionPane.WARNING_MESSAGE);
  165.                 System.exit(0);
  166.  
  167.             }
  168.             else
  169.             {
  170.  
  171.             }
  172.  
  173.         }
  174.     }
  175.     static class Help implements ActionListener{
  176.  
  177.         public final void actionPerformed(ActionEvent e) {
  178.             JFrame HelpFrame = new JFrame("Help");
  179.             HelpFrame.setSize(300,300);
  180.             JPanel pane = new JPanel();
  181.             BorderLayout box = new BorderLayout();
  182.             pane.setLayout(box);
  183.             HelpFrame.setVisible(true);
  184.             HelpFrame.setSize(500,300);
  185.             JLabel freeTrial = new JLabel("Free Trial");
  186.             freeTrial.setFont(new Font("Serif", Font.BOLD, 48));
  187.             JLabel info = new JLabel(" Info: \b CyberSafe is a " +
  188.             "new online seure banking software. \b CyberSafe has won over 20 awards from" +
  189.             "leading banks and online money services. \bThis copy \b of CyberSafe is a free trial license.");
  190.            
  191.             JLabel infocont = new JLabel("\n CyberSafe is the world's leading" +
  192.                     " banking software on the net." +
  193.                     "Please contact your administrator for more information on " +
  194.             "how to use CyberSafe.");
  195.             BorderLayout box1 = new BorderLayout();
  196.             pane.setLayout(box1);
  197.             pane.add(info, BorderLayout.NORTH);
  198.             pane.add(infocont, BorderLayout.CENTER);
  199.             HelpFrame.add(pane);
  200.         }
  201.     }
  202.     static class ViewAccount implements ActionListener{
  203.  
  204.         public final void actionPerformed(ActionEvent e) {
  205.  
  206.             JFrame ViewAccount = new JFrame("View Account");
  207.             ViewAccount.setSize(300, 300);
  208.             JPanel pane = new JPanel();
  209.             BorderLayout box = new BorderLayout();
  210.             pane.setLayout(box);
  211.             ViewAccount.setVisible(true);
  212.             ViewAccount.setSize(301,301);
  213.             JLabel work = new JLabel("Please work on the help and this section.");
  214.             pane.add(work);
  215.             ViewAccount.add(pane);
  216.  
  217.  
  218.         }
  219.     }
  220.     static class Withdrawls implements ActionListener{
  221.  
  222.         public final void actionPerformed(ActionEvent e) {
  223.  
  224.             Withdrawls = new JFrame("Withdrawls");
  225.             Withdrawls.setSize(300, 300);
  226.             JPanel pane = new JPanel();
  227.             FlowLayout flo = new FlowLayout();
  228.             pane.setLayout(flo);
  229.             Withdrawls.setVisible(true);
  230.             Withdrawls.setSize(301,301);
  231.            
  232.             x=32+78;
  233.             work = new JLabel("You have: " +(x)+" dollars.");
  234.             JLabel withdrawAmmount = new JLabel("Ammount to withdraw:");
  235.            
  236.             moneyInput = new JTextField(10);
  237.             withdrawButton = new JButton("Withdraw");
  238.  
  239.  
  240.             pane.add(work);
  241.             pane.add(withdrawAmmount);
  242.             pane.add(moneyInput);
  243.             pane.add(withdrawButton);
  244.             Withdrawls.add(pane);
  245.             withdrawButton.addActionListener(new Withdraw());
  246.             Withdrawls.setSize(387,593);
  247.  
  248.  
  249.  
  250.         }
  251.     }
  252.     static class Transfers implements ActionListener{
  253.  
  254.         public final void actionPerformed(ActionEvent e) {
  255.             JFrame Transfers = new JFrame("Transfers");
  256.             Transfers.setSize(300,300);
  257.             JPanel pane = new JPanel();
  258.             BoxLayout box = new BoxLayout(pane, BoxLayout.Y_AXIS);
  259.             pane.setLayout(box);
  260.             Transfers.setVisible(true);
  261.             Transfers.setSize(500,300);
  262.             JLabel emaillbl = new JLabel("Transfer money to (email address): ");
  263.             JTextField email = new JTextField(10);
  264.             JTextField ammount = new JTextField(10);
  265.             JLabel ammtlbl = new JLabel("Ammount: ");
  266.             JPanel row3 = new JPanel();
  267.             JLabel messageLabel = new JLabel("Message: ");
  268.             row3.add(messageLabel);
  269.             JTextArea message = new JTextArea(4, 22);
  270.             message.setLineWrap(true);
  271.             message.setWrapStyleWord(true);
  272.             JScrollPane scroll = new JScrollPane(message,
  273.                     JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
  274.                     JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
  275.             row3.add(scroll);
  276.             JButton ok = new JButton("Send");
  277.  
  278.             pane.add(emaillbl);
  279.             pane.add(email);
  280.             pane.add(ammtlbl);
  281.             pane.add(ammount);
  282.             pane.add(row3);
  283.  
  284.             pane.add(ok);
  285.             Transfers.add(pane);
  286.             ok.addActionListener(new  MoneySent());
  287.         }
  288.     }
  289.     static class MoneySent implements ActionListener{
  290.  
  291.         public final void actionPerformed(ActionEvent e) {
  292.  
  293.             JOptionPane.showMessageDialog(null, "Money has been sent!");
  294.         }
  295.     }
  296.     static class Withdraw implements ActionListener{
  297.  
  298.         public final void actionPerformed(ActionEvent e) {
  299.  
  300.             int ans;
  301.             String moneyReturn = moneyInput.getText();
  302.             ans = JOptionPane.showConfirmDialog(null, "Are you sure you want to withdraw: "+(moneyInput.getText())+"?");
  303.             work = new JLabel ("You have: " +(moneyInput.getText())+" dollars.");
  304.             Withdrawls.add(work);
  305.            
  306.            
  307.         }
  308.     }
  309.     //Login
  310.     static class Login implements ActionListener{
  311.  
  312.  
  313.  
  314.        
  315.         public final void actionPerformed(ActionEvent e) {
  316.            
  317.             passFrame.setSize(352, 100);
  318.             passFrame.setVisible(true);
  319.             FlowLayout flo = new FlowLayout();
  320.             passFrame.setLayout(flo);
  321.  
  322.  
  323.             JLabel userLabel = new JLabel("Username: \n \n ");
  324.             passFrame.add(userLabel);
  325.             username = new JTextField(10);
  326.             passFrame.add(username);
  327.             JLabel passLabel = new JLabel("Password: \n \n");
  328.             passFrame.add(passLabel);
  329.             passEntry = new JPasswordField(10);
  330.             passEntry.setEchoChar('*');
  331.             passFrame.add(passEntry);
  332.             //set window to center of screen
  333.             passFrame.setLocationRelativeTo(null);
  334.             //The HTML in the button can actually wo78rk!
  335.             JButton ok = new JButton("<html><b>OK</b></html>");
  336.             passFrame.add(ok);
  337.             passFrame.setSize(610, 80);
  338.             ok.addActionListener(new  usernameCheck());
  339.            
  340.            
  341.            
  342.            
  343.            
  344.         }
  345.        
  346.         static class usernameCheck implements ActionListener{
  347.  
  348.            
  349.             public final void actionPerformed(ActionEvent e) {
  350.                 String amazingmiki = "amazingmiki";
  351.                 String tatitos = "Tatitos";
  352.                 char [] Chars;
  353.                 String Word;
  354.                 Chars = passEntry.getPassword();
  355.                 Word = new String(Chars);
  356.                 menuFrame.setSize(300,300);
  357.                
  358.              
  359.                 BorderLayout box = new BorderLayout();
  360.                
  361.                 passFrame.setVisible(false);
  362.                
  363.  
  364.  
  365.                
  366.  
  367.                
  368.  
  369.  
  370.                 //please set button click
  371.                 JButton Transfer = new JButton ("Transfer");
  372.                 //please set button click
  373.                 JButton Withdrawls = new JButton ("Withdrawls");
  374.                 //please set button click
  375.                 JButton VA = new JButton ("View Account");
  376.                 //please set button click
  377.                 JButton Help1 = new JButton("Help");
  378.                 //please set button click
  379.                 JButton SO = new JButton("Sign Out");
  380.  
  381.  
  382.                 menuFrame.setSize(301,301);
  383.                 JPanel pane = new JPanel();
  384.                 menuFrame.add(pane);
  385.  
  386.                 pane.add(Transfer, BorderLayout.SOUTH);
  387.                 pane.add(Withdrawls, BorderLayout.WEST);
  388.                 pane.add(VA, BorderLayout.CENTER);
  389.                 pane.add(Help1, BorderLayout.EAST);
  390.                 pane.add(SO, BorderLayout.NORTH);
  391.                 menuFrame.add(pane);
  392.                 SO.addActionListener(new  SIGNOUT());
  393.                 Help1.addActionListener(new  Help());
  394.                 VA.addActionListener(new  ViewAccount());
  395.                 //please think about some code for View Account and
  396.                 //see what to do w/ it.
  397.                 Withdrawls.addActionListener(new  Withdrawls());
  398.                 Transfer.addActionListener(new  Transfers());
  399.                 menuFrame.setVisible(true);
  400.                 pane.setLayout(box);
  401.            
  402.                
  403.                
  404.                 if (Word.equals(tatitos) && (username.getText().equals(amazingmiki)) ){
  405.                 System.out.println("Login Success!");
  406.                 System.out.println("woohoo!");
  407.                 menuFrame.setVisible(true);
  408.                 passFrame.setVisible(false);
  409.                
  410.                 //Do what you want it to do
  411.                    
  412.                 }
  413.                 else{
  414.                     System.out.println("Login Error");
  415.                     menuFrame.setVisible(false);
  416.                 }
  417.                 //Get text()!
  418.                
  419.                
  420.             }
  421.         }
  422.        
  423.  
  424.        
  425.        
  426.     }
  427. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement