?? actionchoice.java
字號:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ActionChoice extends JFrame implements ActionListener{
JPanel panel1 ;
JLabel labelbj,labeltopic,infolabel;
JButton SaveBtn,OutBtn,BalanceBtn,UserinfoBtn,returnBtn,ExitBtn,PwchangeBtn;
Account acc;
Userinfo user;
String info;
public ActionChoice(Account a1, Userinfo u1)
{
acc=a1;
user=u1;
GridBagLayout layout = new GridBagLayout();
setLayout(layout);
labeltopic = new JLabel(" ");
infolabel = new JLabel(" ");
SaveBtn = new JButton("存 錢");
OutBtn = new JButton("取 錢");
BalanceBtn = new JButton("查詢余額");
UserinfoBtn = new JButton("用戶信息");
ExitBtn = new JButton("安全退出");
PwchangeBtn=new JButton("修改密碼");
returnBtn = new JButton ("返回上一層");
labelbj = new JLabel();
ImageIcon img = new ImageIcon( "bj04.jpg ");
labelbj.setIcon(img);
getLayeredPane().add(labelbj, new Integer(Integer.MIN_VALUE));
labelbj.setBounds(0,0,img.getIconWidth(), img.getIconHeight());
((JPanel)getContentPane()).setOpaque(false);
SaveBtn.addActionListener(this);
OutBtn.addActionListener(this);
BalanceBtn.addActionListener(this);
UserinfoBtn.addActionListener(this);
ExitBtn.addActionListener(this);
PwchangeBtn.addActionListener(this);
returnBtn.addActionListener(this);
// 設置布局都是在這里實現的。。。。
add(labeltopic, new GBC(0, 0,2,1));
add(infolabel, new GBC(0, 2,2,3));
add(SaveBtn, new GBC(0, 1).setWeight(100, 100));
add(OutBtn, new GBC(1, 1).setWeight(100, 100));
add(BalanceBtn, new GBC(2, 1).setWeight(100, 100));
add(UserinfoBtn, new GBC(0, 5).setWeight(100, 100));
add(ExitBtn, new GBC(3,5).setWeight(100, 100));
add(PwchangeBtn, new GBC(3,1).setWeight(100, 100));
add(returnBtn, new GBC(1,5).setWeight(100, 100));
setSize(500,480);
setLocation(250,250);
// 設置這個窗體關閉按鈕的操作. 這里是設置為彈出對話框,并關閉整個系統!
this.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
JOptionPane.showMessageDialog(null," 關閉整個系統!");
System.exit(0);
}
}
);
}
public void actionPerformed(ActionEvent e) {
// TODO 自動生成方法存根
if(e.getSource()== SaveBtn)
{
acc.Save();
}
else if(e.getSource()== OutBtn)
{
acc.Out();
}
else if(e.getSource()== BalanceBtn)
{
String str = "您當前的余額為: " +acc.getAmount();
JOptionPane.showMessageDialog(null,str);
}
else if(e.getSource()== UserinfoBtn)
{
info = "<html><font color=blue><p>您的用戶信息:</p><p>姓 名: "+user.Getname()+"</p><p>性 別: "+user.Getsex()+"</p><p>身份證號:"+user.Getidnum()+"</p><p>手機號碼:"+user.Getphonenum()+"</p><p>地 址:"+user.Getaddress()+"</p><p>郵政編碼:"+user.Getpostcode()+"</p>" +
"<p>密碼:"+acc.getPassword()+"</p><</font></html>";
infolabel.setText(info);
}
else if(e.getSource()== PwchangeBtn)
{
acc.Pwchange();
}
else if(e.getSource()== ExitBtn)
{
JOptionPane.showMessageDialog(null,"謝謝使用ATM系統");
System.exit(0);
}
else if(e.getSource()== returnBtn)
{
MainFrame mainframe = new MainFrame();
mainframe.setVisible(true);
this.setVisible(false);
}
}
public class mo()
{
Mai}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -