Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import javax.swing.*;
- import java.awt.event.*;
- import java.io.PrintWriter;
- import java.io.File;
- public class BankSimulator extends JFrame implements ActionListener
- {
- JTextField username = new JTextField(10);
- JTextField password = new JTextField(10);
- JTextField name = new JTextField(10);
- JTextField setPassword = new JTextField(5);
- JLabel userlbl = new JLabel("Username");
- JLabel passlbl = new JLabel("Password");
- JRadioButton option1 = new JRadioButton("Basic Account");
- JRadioButton option2 = new JRadioButton("Saver Account");
- JRadioButton option3 = new JRadioButton("Super Account");
- JButton logbtn = new JButton("Log In");
- JButton regbtn = new JButton("Register");
- JButton showkeyboard = new JButton("showkeyboard");
- JButton createbtn = new JButton("Create Account");
- JButton[] btn1 = new JButton[10];
- JButton[] btn2 = new JButton[10];
- JButton[] btn3 = new JButton[9];
- JButton[] btn4 = new JButton[7];
- public static void main(String[] args)
- {
- BankSimulator bm = new BankSimulator();
- }
- public BankSimulator()
- {
- setLayout(null);
- setSize(850,700);
- setTitle("Bank Simulator");
- username.setBounds(350, 150, 130, 20);
- add(username);
- password.setBounds(350,180,130,20);
- add(password);
- option1.setBounds(440,180, 130,20);
- option2.setBounds(440,210, 130,20);
- option3.setBounds(440,240, 130, 20);
- add(option1);
- add(option2);
- add(option3);
- option1.setVisible(false);
- option2.setVisible(false);
- option3.setVisible(false);
- name.setBounds(440,150,130,20);
- add(name);
- name.setVisible(false);
- setPassword.setBounds(440,123,130,20);
- add(setPassword);
- setPassword.setVisible(false);
- userlbl.setBounds(288,150,130,20);
- add(userlbl);
- passlbl.setBounds(288,180, 130,20);
- add(passlbl);
- logbtn.setBounds(341,220,150,30);
- add(logbtn);
- createbtn.setBounds(435,270,150,30);
- add(createbtn);
- createbtn.setVisible(false);
- logbtn.addActionListener(this);
- regbtn.setBounds(341,260,150,30);
- add(regbtn);
- regbtn.addActionListener(this);
- showkeyboard.setBounds(341, 270, 150,30);
- add(showkeyboard);
- showkeyboard.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e) {
- showkeyboard();
- }
- });
- setVisible(true);
- }
- public void showkeyboard()
- {
- String nos = "1234567890";
- String alphabet = "abcdefghij";
- String alphabet1 = "klmnopqrs";
- String alphabet2 = "tuvwxyz";
- JFrame myFrame = new JFrame();
- myFrame.setSize(586, 205);
- JPanel myPanel = new JPanel();
- JPanel myPanel1 = new JPanel();
- JPanel myPanel2 = new JPanel();
- JPanel myPanel3 = new JPanel();
- for (int i =0; i< nos.length(); i++)
- {
- btn1[i] = new JButton(nos.substring(i, i + 1));
- myPanel.add(btn1[i]);
- btn1[i].addActionListener(new ActionListener(){
- public void actionPerformed(ActionEvent e)
- {
- keyboardButtonPressed();
- }});
- for (int i = 0; i < alphabet.length(); i++) {
- btn2[i] = new JButton(alphabet.substring(i, i + 1));
- myPanel1.add(btn2[i]);
- }
- for(int i = 0; i < alphabet1.length();i++){
- btn3[i] = new JButton(alphabet1.substring(i, i + 1));
- myPanel2.add(btn3[i]);
- }
- for (int i = 0; i < alphabet2.length(); i++){
- btn4[i] = new JButton(alphabet2.substring(i, i + 1));
- myPanel3.add(btn4[i]);
- }
- JPanel outer = new JPanel();
- outer.add(myPanel);
- outer.add(myPanel1);
- outer.add(myPanel2);
- outer.add(myPanel3);
- myFrame.add(outer);
- myFrame.setVisible(true);
- }
- }
- public String keyboardButtonPressed(char a)
- {
- String alreadyDisplayed = username.getText();
- String toDisplay = alreadyDisplayed + btn1[i].getText();
- }
- public void actionPerformed(ActionEvent e)
- {
- if (e.getSource()== regbtn)
- {
- username.setVisible(false);
- password.setVisible(false);
- logbtn.setVisible(false);
- userlbl.setVisible(false);
- passlbl.setVisible(false);
- option1.setVisible(true);
- option2.setVisible(true);
- option3.setVisible(true);
- name.setVisible(true);
- setPassword.setVisible(true);
- regbtn.setVisible(false);
- createbtn.setVisible(true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement