⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 businesspanel.java

📁 电子银行系统
💻 JAVA
字号:
package bamclient;import javax.swing.*;import javax.swing.border.EmptyBorder;import java.awt.*;import model.*;public class BusinessPanel 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 label4=new JLabel("信用额度:",SwingConstants.CENTER);	private JLabel label5=new JLabel("贷款额:",SwingConstants.CENTER);	private JLabel accountLabel=new JLabel("",SwingConstants.CENTER);	private JLabel nameLabel=new JLabel("",SwingConstants.CENTER);	private JLabel balanceLabel=new JLabel("",SwingConstants.CENTER);	private JLabel ceilingLabel=new JLabel("",SwingConstants.CENTER);	private JLabel loanLabel=new JLabel("",SwingConstants.CENTER);	//用来选择交易种类	private JComboBox choiceBox=new JComboBox();	//用来输入交易金额	private JTextField inputField=new JTextField(15);	private JButton okButton=new JButton("提交");		public JComboBox getChoiceBox() {		return choiceBox;	}	public JTextField getInputField() {		return inputField;	}	public JButton getOkButton() {		return okButton;	}			//构造方法用来设置常规的界面,但有些组件的文本内容需要根据Account对象来设置	public BusinessPanel(){		this.setBorder(new EmptyBorder(10,0,10,0));		this.setLayout(new BorderLayout());				JPanel p=new JPanel();		p.setLayout(new GridLayout(5,2,0,10));		p.add(label1);		p.add(accountLabel);		p.add(label2);		p.add(nameLabel);		p.add(label3);		p.add(balanceLabel);		p.add(label4);		p.add(ceilingLabel);		p.add(label5);		p.add(loanLabel);				this.add(p);				JPanel p2=new JPanel();		choiceBox.addItem("存款");		choiceBox.addItem("取款");				p2.add(choiceBox);		p2.add(inputField);		p2.add(okButton);				this.add(p2,"South");	}		//用来根据账户的类型设置组件,不需要的组件变灰	public void initComponent(Account c){		if (c instanceof CreditAccount) {			choiceBox.addItem("设置透支额度");		}		else{			label4.setEnabled(false);		}		if (c instanceof Loannable){			choiceBox.addItem("申请贷款");			choiceBox.addItem("还贷款");		}		else{			label5.setEnabled(false);		}	}		//用来将账户的信息写在界面中	public void setText(Account c){		accountLabel.setText(c.getId()+"");		nameLabel.setText(c.getName());		balanceLabel.setText(c.getBalance()+"");		if (c instanceof CreditAccount){			CreditAccount ca=(CreditAccount)c;			ceilingLabel.setText(ca.getCeiling()+"");		}		if (c instanceof Loannable){			Loannable l=(Loannable)c;			loanLabel.setText(l.getLoan()+"");		}	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -