/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package MainForm;
/**
*
* @author Linux
*/
import java.awt.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import java.awt.event.*;
import login.Login;
import user.userBean;
public class inputMoney extends JFrame implements ActionListener{
Container contentPane;
JPanel centerPanel=new JPanel();
JPanel centerdownPanel=new JPanel();
JPanel eastPanel=new JPanel();
JPanel westPanel=new JPanel();
JPanel downPanel=new JPanel();
Dimension facesize=new Dimension(800,500);
JLabel jLabel=new JLabel();
JLabel jLabel1=new JLabel();
JLabel jLabel2=new JLabel();
JLabel jLabel3=new JLabel();
JLabel jLabel4=new JLabel();
JTextField Jtf=new JTextField();
JButton input100=new JButton();
JButton input200=new JButton();
JButton input500=new JButton();
JButton input1000=new JButton();
JButton reset=new JButton();
JButton confirm=new JButton();
JButton goback=new JButton();
JButton exit=new JButton();
GridBagLayout gridBag=new GridBagLayout();
GridBagConstraints gridBagCon;
public inputMoney(){
this.setSize(facesize);
this.setResizable(false);
this.setTitle("存款页");
Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation((screenSize.width-400)/2, (screenSize.height-300)/2+45);
try{
Init();
}catch(Exception e){
e.printStackTrace();
}
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void Init()throws Exception{
contentPane=this.getContentPane();
contentPane.setLayout(new BorderLayout());
centerPanel.setLayout(gridBag);
jLabel.setText("请选择存款额:");
jLabel.setFont(new Font("Dialog",0,12));
gridBagCon=new GridBagConstraints();
gridBagCon.gridx=0;
gridBagCon.gridy=0;
gridBagCon.insets=new Insets(10,15,10,1);
gridBag.setConstraints(jLabel, gridBagCon);
centerPanel.add(jLabel);
Jtf.setText("整数存款额");
Jtf.setEditable(false);
Jtf.setBackground(Color.gray);
gridBagCon=new GridBagConstraints();
gridBagCon.gridx=1;
gridBagCon.gridy=0;
gridBagCon.insets=new Insets(10,1,10,10);
gridBag.setConstraints(Jtf, gridBagCon);
centerPanel.add(Jtf);
westPanel.setLayout(gridBag);
input100.setText("10");
input100.setFont(new Font("Dialog",0,15));
gridBagCon=new GridBagConstraints();
gridBagCon.gridx=0;
gridBagCon.gridy=0;
gridBagCon.insets=new Insets(10,10,10,1);
gridBag.setConstraints(input100, gridBagCon);
westPanel.add(input100);
jLabel2.setText(" ");
jLabel2.setFont(new Font("Dialog",0,15));
gridBagCon=new GridBagConstraints();
gridBagCon.gridx=0;
gridBagCon.gridy=1;
gridBagCon.insets=new Insets(10,10,10,1);
gridBag.setConstraints(jLabel2, gridBagCon);
westPanel.add(jLabel2);
input500.setText("20");
input500.setFont(new Font("Dialog",0,15));
gridBagCon=new GridBagConstraints();
gridBagCon.gridx=0;
gridBagCon.gridy=2;
gridBagCon.insets=new Insets(10,15,10,1);
gridBag.setConstraints(input500, gridBagCon);
westPanel.add(input500);
jLabel3.setText(" ");
jLabel3.setFont(new Font("Dialog",0,15));
gridBagCon=new GridBagConstraints();
gridBagCon.gridx=0;
gridBagCon.gridy=3;
gridBagCon.insets=new Insets(10,10,10,1);
gridBag.setConstraints(jLabel3, gridBagCon);
westPanel.add(jLabel3);
goback.setText("返回");
goback.setFont(new Font("Dialog",0,15));
gridBagCon=new GridBagConstraints();
gridBagCon.gridx=0;
gridBagCon.gridy=4;
gridBagCon.insets=new Insets(10,15,10,10);
gridBag.setConstraints(goback, gridBagCon);
westPanel.add(goback);
eastPanel.setLayout(gridBag);
input200.setText("50");
input200.setFont(new Font("Dialog",0,15));
gridBagCon=new GridBagConstraints();
gridBagCon.gridx=0;
gridBagCon.gridy=0;
gridBagCon.insets=new Insets(10,10,10,1);
gridBag.setConstraints(input200,gridBagCon);
eastPanel.add(input200);
jLabel1.setText(" ");
jLabel1.setFont(new Font("Dialog",0,15));
gridBagCon=new GridBagConstraints();
gridBagCon.gridx=0;
gridBagCon.gridy=1;
gridBagCon.insets=new Insets(10,10,10,1);
gridBag.setConstraints(jLabel1, gridBagCon);
eastPanel.add(jLabel1);
input1000.setText("100");
input1000.setFont(new Font("Dialog",0,15));
gridBagCon=new GridBagConstraints();
gridBagCon.gridx=0;
gridBagCon.gridy=2;
gridBagCon.insets=new Insets(10,15,10,1);
gridBag.setConstraints(input1000,gridBagCon);
eastPanel.add(input1000);
jLabel4.setText(" ");
jLabel4.setFont(new Font("Dialog",0,15));
gridBagCon=new GridBagConstraints();
gridBagCon.gridx=0;
gridBagCon.gridy=3;
gridBagCon.insets=new Insets(10,10,10,1);
gridBag.setConstraints(jLabel4, gridBagCon);
eastPanel.add(jLabel4);
exit.setText("退出");
exit.setFont(new Font("Dialog",0,15));
gridBagCon=new GridBagConstraints();
gridBagCon.gridx=0;
gridBagCon.gridy=4;
gridBagCon.insets=new Insets(10,15,10,1);
gridBag.setConstraints(exit, gridBagCon);
eastPanel.add(exit);
contentPane.add(centerPanel,BorderLayout.CENTER);
contentPane.add(eastPanel,BorderLayout.EAST);
contentPane.add(westPanel,BorderLayout.WEST);
goback.addActionListener(this);
exit.addActionListener(this);
input100.addActionListener(this);
input200.addActionListener(this);
input500.addActionListener(this);
input1000.addActionListener(this);
}
public void downInit()throws Exception{
confirm.setText("确定");
confirm.setFont(new Font("Dialog",0,12));
downPanel.add(confirm);
reset.setText("重置");
reset.setFont(new Font("Dialog",0,12));
downPanel.add(reset);
contentPane.add(downPanel,BorderLayout.SOUTH);
confirm.addActionListener(this);
reset.addActionListener(this);
}
public void actionPerformed(ActionEvent e){
Object obj=e.getSource();
String srm;
int rest;
int rm;
if(obj==input100){
Jtf.setText("10");
}else if(obj==input200){
Jtf.setText("50");
}else if(obj==input500){
Jtf.setText("20");
}else if(obj==input1000){
Jtf.setText("100");
}else if(obj==goback){
this.dispose();
mainForm mf=new mainForm();
try {
mf.downInit();
mf.pack();
mf.setVisible(true);
} catch (Exception ex) {
Logger.getLogger(getMoney.class.getName()).log(Level.SEVERE, null, ex);
}
}else if(obj==exit){
this.dispose();
}else if(obj==confirm){
if(Jtf.getText()==null||Jtf.getText().equals("")){
JOptionPane.showMessageDialog(null,"请输入您的存款额!");
}
else
{
userBean ub=new userBean();
rest=ub.search(Login.username);
rm=Integer.parseInt(Jtf.getText())+rest;
if(rm>0&&rm<65500){
ub.inputMoney(Login.username,rm);
JOptionPane.showMessageDialog(null,