📄 atm界面.txt
字号:
import javax.swing.*;
import java.awt.*;
import javax.swing.border.*;
import java.awt.event.*;
class MyAtm extends JFrame implements ActionListener
{
String user = "123456";
boolean loginStatus = false;
JTabbedPane tabbedPane;
JPanel flowLayoutPanel;
JPanel borderLayoutPanel;
JPanel alterPanel;
Box boxLayoutPanel;
FlowLayout flow;
BorderLayout border;
FlowLayout flow1;
JLabel account;
JLabel password;
JLabel new1Label;
JLabel oldLabel;
JLabel new2Label;
JTextField receiveInput;
JPasswordField passwordField;
JPasswordField oldField;
JPasswordField new1Field;
JPasswordField new2Field;
JButton btn1, btn2, btn3, btn4, btn5, btn6, btn7, btn8,
btn9, btn0, btn00, btn, btnStar;
JButton exit1;
JButton enterButton;
JButton cancelButton;
JButton withdrawal;
JButton deposit;
JButton transfer;
JButton exit;
JButton inquiryButton;
JButton exit2;
JButton alter;
JButton exit3;
JTextArea text;
JTextArea businessArea;
JTextArea inquiryText;
Font font;
Container con;
public MyAtm(String s)
{
super(s);
account = new JLabel("Account ");
// account.setBackground(Color.blue);
password = new JLabel("Password");
// password.setBackground(Color.blue);
receiveInput = new JTextField(11);
// receiveInput.setBackground(Color.pink);
passwordField = new JPasswordField(10);
// passwordField.setBackground(Color.pink);
// JButton btn1, btn2, btn3, btn4, btn5, btn6, btn7, btn8, btn9, btn0, btn00, btn, btnStar;
//setBackground(Color.blue);//??
btn1=new JButton("1");
// btn1.setBackground(Color.pink);
btn1.addActionListener(this);
btn2=new JButton("2");
// btn2.setBackground(Color.pink);
btn2.addActionListener(this);
btn3=new JButton("3");
// btn3.setBackground(Color.pink);
btn3.addActionListener(this);
btn4=new JButton("4");
// btn4.setBackground(Color.pink);
btn4.addActionListener(this);
btn5=new JButton("5");
// btn5.setBackground(Color.pink);
btn5.addActionListener(this);
btn6=new JButton("6");
// btn6.setBackground(Color.pink);
btn6.addActionListener(this);
btn7=new JButton("7");
// btn7.setBackground(Color.pink);
btn7.addActionListener(this);
btn8=new JButton("8");
// btn8.setBackground(Color.pink);
btn8.addActionListener(this);
btn9=new JButton("9");
// btn9.setBackground(Color.pink);
btn9.addActionListener(this);
btn0=new JButton("0");
// btn0.setBackground(Color.pink);
btn0.addActionListener(this);
btn00=new JButton("00");
// btn00.setBackground(Color.pink);
btn00.addActionListener(this);
btn = new JButton(".");
// btn.setBackground(Color.pink);
btn.addActionListener(this);
btnStar = new JButton("*");
// btnStar.setBackground(Color.pink);
btnStar.addActionListener(this);
JButton exit1 = new JButton("Exit");
// exit1.setBackground(Color.pink);
exit1.addActionListener(this);
enterButton = new JButton("Sure");
// enterButton.setBackground(Color.pink);
enterButton.addActionListener(this);
cancelButton = new JButton("Cancel");
// cancelButton.setBackground(Color.pink);
cancelButton.addActionListener(this);
text= new JTextArea(" \n\n Welcome to\n ** Bank \n ATM \n (Login first!)");
Font font=new Font("Arial",Font.BOLD,30);
text.setFont(font);
text.setEditable(false);
text.setBackground(Color.pink);
setBounds(100, 100, 300 ,300);
setVisible(true);
tabbedPane = new JTabbedPane(JTabbedPane.LEFT);
flow = new FlowLayout();//flow
flowLayoutPanel = new JPanel();
flow.setAlignment(FlowLayout.LEFT);//flow
flow.setVgap(6);//flow????4
flow.setHgap(10);//????5
flowLayoutPanel.setLayout(flow);
flowLayoutPanel.add(account);
flowLayoutPanel.add(receiveInput);
flowLayoutPanel.add(password);
flowLayoutPanel.add(passwordField);
flowLayoutPanel.add(btn1);
flowLayoutPanel.add(btn2);
flowLayoutPanel.add(btn3);
flowLayoutPanel.add(btn4);
flowLayoutPanel.add(btn5);
flowLayoutPanel.add(btn6);
flowLayoutPanel.add(btn7);
flowLayoutPanel.add(btn8);
flowLayoutPanel.add(btn9);
flowLayoutPanel.add(btn0);
flowLayoutPanel.add(btn00);
flowLayoutPanel.add(btn);
flowLayoutPanel.add(btnStar);
flowLayoutPanel.add(enterButton);
flowLayoutPanel.add(cancelButton);
flowLayoutPanel.add(exit1);
flowLayoutPanel.setBackground(Color.pink);
withdrawal = new JButton("Withdrawal");
deposit = new JButton(" Deposit ");
transfer = new JButton(" Transfer ");
exit = new JButton("Exit");
exit.addActionListener(this);
businessArea = new JTextArea();
boxLayoutPanel = Box.createVerticalBox();
boxLayoutPanel.add(withdrawal);
boxLayoutPanel.add(deposit);
boxLayoutPanel.add(transfer);
boxLayoutPanel.add(businessArea);
// boxLayoutPanel.add(enterButton);
boxLayoutPanel.add(exit);
//boxLayoutPanel.setBackground(Color.pink);
inquiryButton = new JButton("Balance Inquiry");
exit2 = new JButton("Exit");
exit2.addActionListener(this);
inquiryText = new JTextArea();
borderLayoutPanel = new JPanel();
border = new BorderLayout();
border.setVgap(6);
border.setHgap(10);
borderLayoutPanel.setLayout(border);
borderLayoutPanel.add(inquiryButton, BorderLayout.NORTH);
borderLayoutPanel.add(inquiryText, BorderLayout.CENTER);
borderLayoutPanel.add(exit2, BorderLayout.SOUTH);
//borderLayoutPanel.setBackground(Color.pink);
alter = new JButton("Alter Password");
exit3 = new JButton("Exit");
exit3.addActionListener(this);
oldLabel = new JLabel("Input the Old Password here");
new1Label = new JLabel("Input the New Password here");
new2Label = new JLabel("Input New Password again");
oldField = new JPasswordField(10);
new1Field = new JPasswordField(10);
new2Field = new JPasswordField(10);
alterPanel = new JPanel();
flow1 = new FlowLayout();
alterPanel.setLayout(flow1);
alterPanel.add(alter);alterPanel.add(exit3);
alterPanel.add(oldLabel);
alterPanel.add(oldField);
alterPanel.add(new1Label);
alterPanel.add(new1Field);
alterPanel.add(new2Label);
alterPanel.add(new2Field);
alterPanel.setBackground(Color.pink);
tabbedPane.add("Homepage", text);
tabbedPane.add("Login",flowLayoutPanel);
tabbedPane.add("Business",boxLayoutPanel);
tabbedPane.add("Inquiry", borderLayoutPanel);
tabbedPane.add("Alter",alterPanel);
tabbedPane.validate();
Container con = getContentPane();
con.setBackground(Color.blue);
con.add(tabbedPane);
con.validate();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent event)
{
if(event.getActionCommand()=="Cancel")
{
// if(event.getSource() == receiveInput)
receiveInput.setText("");
// if(event.getSource() == passwordField)
// receiveInput.setText("");
}
if(event.getActionCommand()=="Exit")
System.exit(0);
if(event.getActionCommand()=="1")
{
receiveInput.setText(receiveInput.getText() + event.getActionCommand());
// if(event.getSource() == passwordField)
// passwordField.setText(passwordField.getText() + event.getActionCommand());
}
if(event.getActionCommand()=="2")
receiveInput.setText(receiveInput.getText() + event.getActionCommand());
if(event.getActionCommand()=="3")
receiveInput.setText(receiveInput.getText() + event.getActionCommand());
if(event.getActionCommand()=="4")
receiveInput.setText(receiveInput.getText() + event.getActionCommand());
if(event.getActionCommand()=="5")
receiveInput.setText(receiveInput.getText() + event.getActionCommand());
if(event.getActionCommand()=="6")
receiveInput.setText(receiveInput.getText() + event.getActionCommand());
if(event.getActionCommand()=="7")
receiveInput.setText(receiveInput.getText() + event.getActionCommand());
if(event.getActionCommand()=="8")
receiveInput.setText(receiveInput.getText() + event.getActionCommand());
if(event.getActionCommand()=="9")
receiveInput.setText(receiveInput.getText() + event.getActionCommand());
if(event.getActionCommand()=="0")
receiveInput.setText(receiveInput.getText() + event.getActionCommand());
if(event.getActionCommand()=="00")
receiveInput.setText(receiveInput.getText() + event.getActionCommand());
if(event.getActionCommand()=="Sure")
{
if((receiveInput.getText()).equals(user))
loginStatus = true;
else
{
JOptionPane.showMessageDialog(null, "Error Account or Password,Input Again!");
receiveInput.setText("");
passwordField.setText("");
}
}
}
}
public class Atm
{
public static void main(String arg[])
{
new MyAtm("ATM");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -