package viewControl;

import entity.Account; import entity.CreditAccount; import entity.Loanable; import service.*;

import javax.swing.; import java.awt.;

public class BusinessControlPanel extends JPanel { private JLabel label1=new JLabel('总余额:',SwingConstants.CENTER); private JLabel label2=new JLabel('总贷款:',SwingConstants.CENTER); private JLabel label3=new JLabel('总透支:',SwingConstants.CENTER); private JLabel balanceLabel=new JLabel('',SwingConstants.CENTER); private JLabel loanLabel=new JLabel('',SwingConstants.CENTER); private JLabel ceilingLabel=new JLabel('',SwingConstants.CENTER); private JComboBox choiceBox=new JComboBox(); private JButton okButton=new JButton('提交');

public JComboBox getChoiceBox() {
    return choiceBox;
}

public JButton getOkButton() {
    return okButton;
}

public BusinessControlPanel(){
    BorderLayout borderLayout=new BorderLayout();
    this.setLayout(borderLayout);
    JPanel top=new JPanel();
    JPanel bottom=new JPanel();
    top.setLayout(new GridLayout(3,2,40,10));
    top.add(label1);
    top.add(balanceLabel);
    top.add(label2);
    top.add(loanLabel);
    top.add(label3);
    top.add(ceilingLabel);
    this.add(top);
    choiceBox.addItem('查询总余额');
    choiceBox.addItem('查询总贷款');
    choiceBox.addItem('查询总透支');
    bottom.add(choiceBox);
    bottom.add(okButton);
    this.add(bottom,'South');
}

public void setAccountInfo(Bank bank){
    balanceLabel.setText(bank.getTotalBal()+"");
    loanLabel.setText(String.valueOf(bank.getTotalLoan()));
    ceilingLabel.setText(bank.getTotalCeiling()+"");
}

public void setBalancenew(Bank bank){
    balanceLabel.setText(bank.getTotalBal()+"");
}

public void setloannew(Bank bank){
    loanLabel.setText(String.valueOf(bank.getTotalLoan()));
}

public void setceilingnew(Bank bank){
    ceilingLabel.setText(bank.getTotalCeiling()+"");
}

public static void main(String[] args) {
    JFrame jf=new JFrame('业务交易界面');
    viewControl.BusinessControlPanel bp=new viewControl.BusinessControlPanel();
    jf.add(bp);
    jf.setSize(600,600);
    jf.setVisible(true);
    jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

}

package viewControl;

import view.LoginPanel;

import javax.swing.; import javax.swing.border.EmptyBorder; import java.awt.;

public class LoginPanelControl extends Panel { private JTextField aidField; private JPasswordField passwordField; private JButton loginButton; private JButton backButton;

public JTextField getAidField() {
    return aidField;
}

public JPasswordField getPasswordField() {
    return passwordField;
}

public JButton getLoginButton() {
    return loginButton;
}

public JButton getBackButton() {
    return backButton;
}

public LoginPanelControl(){
    aidField=new JTextField();
    passwordField=new JPasswordField();
    loginButton=new JButton('登录');
    BorderLayout borderLayout=new BorderLayout();
    this.setLayout(borderLayout);
    JPanel top=new JPanel();
    JPanel bottom=new JPanel();
    GridLayout gridLayout=new GridLayout(2,2,0,60);
    top.setLayout(gridLayout);
    top.setBorder(new EmptyBorder(40,0,50,30));
    top.add(new JLabel('账号:',SwingConstants.CENTER));
    top.add(aidField);
    top.add(new JLabel('密码:',SwingConstants.CENTER));
    top.add(passwordField);
    this.add(top);
    GridLayout gridLayout1=new GridLayout(1,1,60,0);
    bottom.setBorder(new EmptyBorder(20,20,20,20));
    bottom.setLayout(gridLayout1);
    bottom.add(loginButton);
    this.add(bottom,'South');
}

public static void main(String[] args) {
    JFrame jf=new JFrame('BAM登录界面');
    LoginPanelControl lp=new LoginPanelControl();
    jf.add(lp);
    jf.setSize(400,400);
    jf.setVisible(true);
    jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

}

package viewControl;

import exception.BusinessException; import exception.LoginException; import service.Bank; import entity.bankAccount; import javax.swing.; import java.awt.; import java.awt.event.ActionEvent; import java.awt.event.ActionListener;

public class MainContol{ JFrame jFrame; bankAccount act; Bank bank; private BusinessControlPanel BusinessControlPanel=new BusinessControlPanel(); private CardLayout cardLayout=new CardLayout(); private LoginPanelControl LoginPanelControl=new LoginPanelControl();

public viewControl.BusinessControlPanel getBusinessControlPanel() {
    return BusinessControlPanel;
}

public CardLayout getCardLayout() {
    return cardLayout;
}

public viewControl.LoginPanelControl getLoginPanelControl() {
    return LoginPanelControl;
}

public MainContol(){

    jFrame=new JFrame('管理系统');
    jFrame.setLayout(cardLayout);
    jFrame.add('register',LoginPanelControl);
    jFrame.add('main',BusinessControlPanel);

    jFrame.setSize(500,450);
    jFrame.setVisible(true);
    jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    bank=new Bank();
    addListeners();
}
public void addListeners(){
    getLoginPanelControl().getLoginButton().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            login();
        }
    });
    getBusinessControlPanel().getOkButton().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            business();
        }
    });
}
public void login(){
    String aidstr=getLoginPanelControl().getAidField().getText();
    long aid=Long.parseLong(aidstr);
    String password= String.valueOf(getLoginPanelControl().getPasswordField().getPassword());

    try {
        if(aid==123456789&&password.equals('123456789')){
            cardLayout.show(jFrame.getContentPane(),'main');
        }
        else throw new LoginException('你的账号密码不正确') ;
    }catch (LoginException e)
    {
        JOptionPane.showMessageDialog(jFrame,e.getMessage());
    }
}
public void business()
{
    String choice=(String)getBusinessControlPanel().getChoiceBox().getSelectedItem();
    if(choice.equals('查询总余额')){
        BusinessControlPanel.setBalancenew(bank);
    }else if(choice.equals('查询总贷款')){
        BusinessControlPanel.setloannew(bank);
    }else if(choice.equals('查询总透支')){
        BusinessControlPanel.setceilingnew(bank);
    }
}

public static void main(String[] args) {
    MainContol mainContol=new MainContol();
}

原文地址: https://www.cveoy.top/t/topic/pN5H 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录