p1.add(label1); p1.add(yue); p1.add(label2);
p2.setBounds(300,80,100,50); p2.add(button1); add(p1); add(p2);
i=Denlu.chaxun(); if(i>=0) {
yue.setText(String.valueOf(i)); } else {
JOptionPane.showMessageDialog(Zhuye.z,\系统故障,请稍后在试!\ }
setVisible(true); }
public class BHandler implements ActionListener { public void actionPerformed (ActionEvent event) { dispose(); } } }
类:Xiugai
package zhuce;
import javax.swing.*;
import zhuce.Zhuanzhang.BHandler;
import java.awt.*;
import java.awt.event.*;
public class Xiugai extends JDialog{ TextField ymima=new TextField(20); TextField xmima=new TextField(20); public Xiugai(JFrame m,String s){ super(m,s);
setBounds(400,250,400,300); setVisible(true); setModal(false);
21
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); setResizable(false);
setLayout(null); //不用任何布局 JLabel label1=new JLabel(\修改密码\
label1.setFont(new Font(\宋体\ JLabel label2=new JLabel(\原密码:\
label2.setFont(new Font(\宋体\ JLabel label3=new JLabel(\新密码:\
label3.setFont(new Font(\宋体\
JButton button1=new JButton(\确认\ JButton button2=new JButton(\取消\ BHandler h=new BHandler(); button1.addActionListener(h); button2.addActionListener(h);
JPanel p1=new JPanel(); JPanel p2=new JPanel(); JPanel p3=new JPanel(); JPanel p4=new JPanel(); p1.setBounds(0,0,250,60); p1.add(label1);
p2.setBounds(25,60,300,40); p2.add(label2); p2.add(ymima);
p3.setBounds(25,100,300,60); p3.add(label3); p3.add(xmima);
p4.setBounds(35,160,300,40); p4.add(button1); p4.add(button2); add(p1); add(p2); add(p3); add(p4);
setVisible(true); }
public class BHandler implements ActionListener { public void actionPerformed (ActionEvent event) {
int i;
if(event.getActionCommand()==\确认
\ {
22
i=Denlu.gaimi(ymima.getText(), xmima.getText()); if(i==1) {
JOptionPane.showMessageDialog(Zhuye.z,\修改密码成功,请重新登录!\
dispose(); Zhuye.close(); }
else if(i==2)
JOptionPane.showMessageDialog(Zhuye.z,\原密码错误!\ else {
JOptionPane.showMessageDialog(Zhuye.z,\系统故障!\ dispose(); } }
else if(event.getActionCommand()==\确认
\
JOptionPane.showMessageDialog(Zhuye.z,\请补全信息!\ else
dispose(); } } }
类:Zc.java
package zhuce;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Zc extends JFrame{
JFrame z=new JFrame(\银行管理系统\ TextField name=new TextField(20); TextField sex=new TextField(20); TextField kahao=new TextField(20); TextField mima=new TextField(20); TextField phone=new TextField(20); public Zc(){
23
Zoc(); }
public void Zoc(){
z.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); z.setBounds(210,110,700,600); z.setVisible(true); z.setResizable(false);
Container c=getContentPane(); //必须继承JFrame类 c.setLayout(null);
c.setBackground(Color.blue);//不采用任何布局方式 z.add(c);
JLabel label1=new JLabel(\客户注册\JLabel label2=new JLabel(\姓 名:\JLabel label3=new JLabel(\性 别:\JLabel label4=new JLabel(\卡 号:\JLabel label5=new JLabel(\密 码:\JLabel label6=new JLabel(\手机号:\
label1.setFont(new Font(\label1.setForeground(Color.WHITE);
label2.setFont(new Font(\label2.setForeground(Color.WHITE);
label3.setFont(new Font(\label3.setForeground(Color.WHITE);
label4.setFont(new Font(\label4.setForeground(Color.WHITE);
label5.setFont(new Font(\label5.setForeground(Color.WHITE);
label6.setFont(new Font(\label6.setForeground(Color.WHITE);
ImageIcon img1=new ImageIcon(\ImageIcon img2=new ImageIcon(\JButton button1=new JButton(\button1.setBackground(Color.blue); JButton button2=new JButton(\
24
相关推荐: