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.io.PrintStream;
- import java.util.Arrays;
- import java.net.*;
- import java.util.*;
- public class login extends JFrame {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- static JFrame passFrame = new JFrame("Login");
- static JTextField username = new JTextField(10);
- static JPasswordField passEntry = new JPasswordField(10);
- static JFrame menuFrame = new JFrame("CyberSafe Menu");
- static JTextField moneyInput = new JTextField(10);
- static JButton withdrawButton = new JButton("Withdraw");
- static int x;
- static JFrame Withdrawls = new JFrame("Withdrawls");
- static JLabel work = new JLabel("You have: " +(x)+" dollars.");
- public static void main(String[] arguments) {
- JFrame loginFrame = new JFrame("Login");
- loginFrame.setSize(1235, 90);
- FlowLayout flo = new FlowLayout();
- JLabel pageLabel = new JLabel("Welcome to CyberSafe. Please Login!");
- //Toolkit.getDefaultToolkit().beep();
- //TextField password1 = new TextField(8);
- //password1.setEchoChar('*');
- JButton submit = new JButton("Login!");
- loginFrame.add(pageLabel);
- loginFrame.add(submit);
- loginFrame.setLayout(flo);
- submit.addActionListener(new Login());
- loginFrame.setVisible(true);
- }
- public login() {
- JFrame pics = new JFrame("Pictures");
- pics.setSize(400, 400);
- pics.setSize(500, 500);
- pics.setSize(501, 501);
- JPanel pane = new JPanel();
- JButton next = new JButton("Next ----->");
- ImageIcon pic1 = new ImageIcon("/Users/amazingmiki/Desktop/pic/gol-de-Forlan.jpg");
- JLabel pic2 = new JLabel(pic1);
- next.addActionListener(new next());
- pics.setVisible(true);
- pane.add(next);
- pane.add(pic2);
- pics.add(pane);
- //TextField
- //JTextField pageAddress = new JTextField(20);
- //Buttons
- //JButton go = new JButton ("GO!");
- //Checkboxes
- //JCheckBox jumboSize = new JCheckBox("Jumbo Size!");
- //JComboBox profession = new JComboBox();
- //TextAreas! With Scroll Bars!
- //JPanel row3 = new JPanel();
- //JLabel messageLabel = new JLabel("Message: ");
- //row3.add(messageLabel);
- //JTextArea message = new JTextArea(4, 22);
- //message.setLineWrap(true);
- //message.setWrapStyleWord(true);
- //JScrollPane scroll = new JScrollPane(message,
- //JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
- //JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
- //row3.add(scroll);
- //Sliders!
- //JSlider guess = new JSlider(JSlider.VERTICAL, 1, 1000, 500);
- //ImageIcons!
- //ImageIcon stopSign = new ImageIcon("stopsign.gif");
- //PasswordFields
- //JTextField password1 = new JTextField(8);
- //FlowLayout is needed!
- FlowLayout flo = new FlowLayout();
- //Items for checkboxes
- // profession.addItem("Butcher");
- //profession.addItem("Computer Scientist");
- //to set CheckBox to editable (User input)
- //profession.setEditable(true);
- setLayout(flo);
- //add items to applet!
- // add(pageAddress);
- //add(go);
- //add(jumboSize);
- //add(profession);
- //add(row3);
- // add(guess);
- pics.setSize(500,400);
- //Visible
- setVisible(true);
- //do action of button submit
- }
- static class next implements ActionListener{
- public final void actionPerformed(ActionEvent e){
- JFrame nxtPic = new JFrame("Pictures");
- nxtPic.setSize(400, 400);
- nxtPic.setSize(500, 500);
- JPanel pane = new JPanel();
- ImageIcon pic1 = new ImageIcon("/Users/amazingmiki/Desktop/pic/Uruguay-vs-Ghana-013.jpg");
- JLabel pic2 = new JLabel(pic1);
- nxtPic.setVisible(true);
- pane.add(pic2);
- nxtPic.add(pane);
- nxtPic.setSize(501, 501);
- }
- }
- //Sign out
- static class SIGNOUT implements ActionListener{
- public final void actionPerformed(ActionEvent e) {
- String ans;
- ans = JOptionPane.showInputDialog(null, "Are you sure you want to sign out?");
- if (ans.equalsIgnoreCase("Yes") || (ans.equalsIgnoreCase("y"))){
- JOptionPane.showMessageDialog(null, "Now closing... Please press OK.", "Status", JOptionPane.WARNING_MESSAGE);
- System.exit(0);
- }
- else
- {
- }
- }
- }
- static class Help implements ActionListener{
- public final void actionPerformed(ActionEvent e) {
- JFrame HelpFrame = new JFrame("Help");
- HelpFrame.setSize(300,300);
- JPanel pane = new JPanel();
- BorderLayout box = new BorderLayout();
- pane.setLayout(box);
- HelpFrame.setVisible(true);
- HelpFrame.setSize(500,300);
- JLabel freeTrial = new JLabel("Free Trial");
- freeTrial.setFont(new Font("Serif", Font.BOLD, 48));
- JLabel info = new JLabel(" Info: \b CyberSafe is a " +
- "new online seure banking software. \b CyberSafe has won over 20 awards from" +
- "leading banks and online money services. \bThis copy \b of CyberSafe is a free trial license.");
- JLabel infocont = new JLabel("\n CyberSafe is the world's leading" +
- " banking software on the net." +
- "Please contact your administrator for more information on " +
- "how to use CyberSafe.");
- BorderLayout box1 = new BorderLayout();
- pane.setLayout(box1);
- pane.add(info, BorderLayout.NORTH);
- pane.add(infocont, BorderLayout.CENTER);
- HelpFrame.add(pane);
- }
- }
- static class ViewAccount implements ActionListener{
- public final void actionPerformed(ActionEvent e) {
- JFrame ViewAccount = new JFrame("View Account");
- ViewAccount.setSize(300, 300);
- JPanel pane = new JPanel();
- BorderLayout box = new BorderLayout();
- pane.setLayout(box);
- ViewAccount.setVisible(true);
- ViewAccount.setSize(301,301);
- JLabel work = new JLabel("Please work on the help and this section.");
- pane.add(work);
- ViewAccount.add(pane);
- }
- }
- static class Withdrawls implements ActionListener{
- public final void actionPerformed(ActionEvent e) {
- Withdrawls = new JFrame("Withdrawls");
- Withdrawls.setSize(300, 300);
- JPanel pane = new JPanel();
- FlowLayout flo = new FlowLayout();
- pane.setLayout(flo);
- Withdrawls.setVisible(true);
- Withdrawls.setSize(301,301);
- x=32+78;
- work = new JLabel("You have: " +(x)+" dollars.");
- JLabel withdrawAmmount = new JLabel("Ammount to withdraw:");
- moneyInput = new JTextField(10);
- withdrawButton = new JButton("Withdraw");
- pane.add(work);
- pane.add(withdrawAmmount);
- pane.add(moneyInput);
- pane.add(withdrawButton);
- Withdrawls.add(pane);
- withdrawButton.addActionListener(new Withdraw());
- Withdrawls.setSize(387,593);
- }
- }
- static class Transfers implements ActionListener{
- public final void actionPerformed(ActionEvent e) {
- JFrame Transfers = new JFrame("Transfers");
- Transfers.setSize(300,300);
- JPanel pane = new JPanel();
- BoxLayout box = new BoxLayout(pane, BoxLayout.Y_AXIS);
- pane.setLayout(box);
- Transfers.setVisible(true);
- Transfers.setSize(500,300);
- JLabel emaillbl = new JLabel("Transfer money to (email address): ");
- JTextField email = new JTextField(10);
- JTextField ammount = new JTextField(10);
- JLabel ammtlbl = new JLabel("Ammount: ");
- JPanel row3 = new JPanel();
- JLabel messageLabel = new JLabel("Message: ");
- row3.add(messageLabel);
- JTextArea message = new JTextArea(4, 22);
- message.setLineWrap(true);
- message.setWrapStyleWord(true);
- JScrollPane scroll = new JScrollPane(message,
- JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
- JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
- row3.add(scroll);
- JButton ok = new JButton("Send");
- pane.add(emaillbl);
- pane.add(email);
- pane.add(ammtlbl);
- pane.add(ammount);
- pane.add(row3);
- pane.add(ok);
- Transfers.add(pane);
- ok.addActionListener(new MoneySent());
- }
- }
- static class MoneySent implements ActionListener{
- public final void actionPerformed(ActionEvent e) {
- JOptionPane.showMessageDialog(null, "Money has been sent!");
- }
- }
- static class Withdraw implements ActionListener{
- public final void actionPerformed(ActionEvent e) {
- int ans;
- String moneyReturn = moneyInput.getText();
- ans = JOptionPane.showConfirmDialog(null, "Are you sure you want to withdraw: "+(moneyInput.getText())+"?");
- work = new JLabel ("You have: " +(moneyInput.getText())+" dollars.");
- Withdrawls.add(work);
- }
- }
- //Login
- static class Login implements ActionListener{
- public final void actionPerformed(ActionEvent e) {
- passFrame.setSize(352, 100);
- passFrame.setVisible(true);
- FlowLayout flo = new FlowLayout();
- passFrame.setLayout(flo);
- JLabel userLabel = new JLabel("Username: \n \n ");
- passFrame.add(userLabel);
- username = new JTextField(10);
- passFrame.add(username);
- JLabel passLabel = new JLabel("Password: \n \n");
- passFrame.add(passLabel);
- passEntry = new JPasswordField(10);
- passEntry.setEchoChar('*');
- passFrame.add(passEntry);
- //set window to center of screen
- passFrame.setLocationRelativeTo(null);
- //The HTML in the button can actually wo78rk!
- JButton ok = new JButton("<html><b>OK</b></html>");
- passFrame.add(ok);
- passFrame.setSize(610, 80);
- ok.addActionListener(new usernameCheck());
- }
- static class usernameCheck implements ActionListener{
- public final void actionPerformed(ActionEvent e) {
- String amazingmiki = "amazingmiki";
- String tatitos = "Tatitos";
- char [] Chars;
- String Word;
- Chars = passEntry.getPassword();
- Word = new String(Chars);
- menuFrame.setSize(300,300);
- BorderLayout box = new BorderLayout();
- passFrame.setVisible(false);
- //please set button click
- JButton Transfer = new JButton ("Transfer");
- //please set button click
- JButton Withdrawls = new JButton ("Withdrawls");
- //please set button click
- JButton VA = new JButton ("View Account");
- //please set button click
- JButton Help1 = new JButton("Help");
- //please set button click
- JButton SO = new JButton("Sign Out");
- menuFrame.setSize(301,301);
- JPanel pane = new JPanel();
- menuFrame.add(pane);
- pane.add(Transfer, BorderLayout.SOUTH);
- pane.add(Withdrawls, BorderLayout.WEST);
- pane.add(VA, BorderLayout.CENTER);
- pane.add(Help1, BorderLayout.EAST);
- pane.add(SO, BorderLayout.NORTH);
- menuFrame.add(pane);
- SO.addActionListener(new SIGNOUT());
- Help1.addActionListener(new Help());
- VA.addActionListener(new ViewAccount());
- //please think about some code for View Account and
- //see what to do w/ it.
- Withdrawls.addActionListener(new Withdrawls());
- Transfer.addActionListener(new Transfers());
- menuFrame.setVisible(true);
- pane.setLayout(box);
- if (Word.equals(tatitos) && (username.getText().equals(amazingmiki)) ){
- System.out.println("Login Success!");
- System.out.println("woohoo!");
- menuFrame.setVisible(true);
- passFrame.setVisible(false);
- //Do what you want it to do
- }
- else{
- System.out.println("Login Error");
- menuFrame.setVisible(false);
- }
- //Get text()!
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement