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

📄 atm.java

📁 ATM系统存款取款用Java实现的源码文件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
  b16.add(Box.createVerticalStrut(60));
  b16.add(b24);
  x9.add(b16);
  x9.setBackground(Color.cyan);
  x9.setForeground(Color.red);
  x10.setBackground(Color.cyan);
  x10.setForeground(Color.red);
  b33.add(y15);
  b33.add(Box.createHorizontalStrut(100));
  b34.add(Box.createVerticalStrut(50));
  b34.add(new Label("转账成功,谢谢使用!"));
  b34.add(Box.createVerticalStrut(100));
  b34.add(b33); 
  x10.add(b34); 
  x11.setBackground(Color.yellow);
  x11.setForeground(Color.blue);
  y16.setBackground(Color.blue);
  y16.setForeground(Color.white);
  b35.add(y16);
  b35.add(Box.createHorizontalStrut(140));
  b36.add(Box.createVerticalStrut(50));
  b36.add(new Label("余额不足,转账失败!"));
  b36.add(Box.createVerticalStrut(100));
  b36.add(b35); 
  x11.add(b36);
  x12.setBackground(Color.cyan);
  x12.setForeground(Color.red);
  b37.add(Box.createHorizontalStrut(150));
  b37.add(y17);
  b38.add(Box.createVerticalStrut(50));
  b38.add(new Label("没有此账号,转账失败!"));
  b38.add(Box.createVerticalStrut(100));
  b38.add(b37);  
  x12.add(b38);  
  x13.setBackground(Color.cyan);
  x13.setForeground(Color.red);
  b41.add(new Label("请输入原密码:"));
  b41.add(Box.createHorizontalStrut(20));
  b41.add(z7);
  b42.add(Box.createHorizontalStrut(300));
  b42.add(y18);
  b43.add(Box.createVerticalStrut(50));
  b43.add(b41);
  b43.add(Box.createVerticalStrut(100));
  b43.add(b42);  
  x13.add(b43); 
  x14.setBackground(Color.cyan);
  x14.setForeground(Color.black);
  b39.add(Box.createHorizontalGlue());
  b39.add(y19);
  b40.add(Box.createVerticalStrut(80));
  b40.add(new Label("    原密码不正确!"));
  b40.add(Box.createVerticalStrut(70));
  b40.add(b39); 
  x14.add(b40); 
  b17.add(new Label("请输入新密码:"));
  b17.add(Box.createHorizontalGlue());
  b18.add(Box.createHorizontalGlue());
  b18.add(z8);
  b19.add(new Label("请确认新密码:"));
  b19.add(Box.createHorizontalGlue());
  b20.add(Box.createHorizontalGlue());
  b20.add(z9);
  b21.add(Box.createHorizontalStrut(200));
  b21.add(y20);
  b22.add(Box.createVerticalStrut(25));
  b22.add(b17);
  b22.add(Box.createVerticalStrut(10));
  b22.add(b18);
  b22.add(Box.createVerticalStrut(30));
  b22.add(b19);
  b22.add(Box.createVerticalStrut(10));
  b22.add(b20);
  b22.add(Box.createVerticalStrut(40));
  b22.add(b21);
  x15.add(b22);
  x16.setBackground(Color.cyan);
  x16.setForeground(Color.blue);
  b44.add(Box.createHorizontalStrut(200));
  b44.add(y21);
  b45.add(Box.createVerticalStrut(50));
  b45.add(new Label("修改成功,请牢记你的密码!"));
  b45.add(Box.createVerticalStrut(100));
  b45.add(b44);
  x16.add(b45);  
  x17.setBackground(Color.green);
  x17.setForeground(Color.blue);
  b46.add(Box.createHorizontalStrut(250));
  b46.add(y22);
  b47.add(Box.createVerticalStrut(70));
  b47.add(new Label("你两次输入的密码不一致,修改密码失败!"));
  b47.add(Box.createVerticalStrut(100));
  b47.add(b46);
  x17.add(b47);  
  panel.add("1",x1);
  panel.add("2",x2);
  panel.add("3",x3);
  panel.add("4",x4);
  panel.add("5",x5);
  panel.add("6",x6);
  panel.add("7",x7);
  panel.add("8",x8);
  panel.add("9",x9);
  panel.add("10",x10);
  panel.add("11",x11);
  panel.add("12",x12);
  panel.add("13",x13);
  panel.add("14",x14);
  panel.add("15",x15);
  panel.add("16",x16);
  panel.add("17",x17);
  add(panel);
  validate();
 }




 public void start()
  {
    try { 
         socket=new Socket(this.getCodeBase().getHost(),4339);
         in=new DataInputStream(socket.getInputStream());
         out=new DataOutputStream(socket.getOutputStream());
        }
    catch  (IOException e){}
  }

 public void stop()
  {try {out.writeUTF("客户离开");}
   catch(IOException e1){}
  }



 public void destroy()
  {
   try{out.writeUTF("客户离开");}
   catch(IOException e1){}
  }



public void actionPerformed(ActionEvent e)
{try {if(e.getSource()==y1||e.getSource()==y2)
    {
     card.show(panel,"2");
     z1.setText(null);
    }
  if(e.getSource()==y3||e.getSource()==y4||e.getSource()==y9)
    {密码=null;登陆帐号=null;转帐号=null;新密码=null;余额=null;temp=null;
     card.show(panel,"1");  
    }    
  if(e.getSource()==y5)
     {temp="查询余额,"+登陆帐号;
      out.writeUTF(temp);
      temp=in.readUTF();
      余额=String.valueOf(temp);
      card.show(panel,"5");
      z3.setText(余额);
     }
  if(e.getSource()==y6)
    {
     card.show(panel,"6");
     z4.setText(null);
    }
  if(e.getSource()==y7)
    {z6.setText(null);
     z6.setEnabled(false);
     card.show(panel,"9");
     z5.setText(null);
     z6.setText("我未被激活");
    }
  if(e.getSource()==y8)
    {
     card.show(panel,"13");
     z7.setText(null);
    }
  if(e.getSource()==y10||e.getSource()==y11||e.getSource()==y12||e.getSource()==y13||e.getSource()==y14||e.getSource()==y15||e.getSource()==y16||e.getSource()==y17||e.getSource()==y18||e.getSource()==y19||e.getSource()==y20||e.getSource()==y21||e.getSource()==y22)
     card.show(panel,"4");
  if(e.getSource()==z1)
    {  登陆帐号=z1.getText();
       temp="验证帐号,"+登陆帐号;
       out.writeUTF(temp);
       temp=in.readUTF();
       if(temp.equals("有"))
       {
        card.show(panel,"3");
        z2.setBackground(Color.yellow);
        z2.setForeground(Color.black);
        z2.setText(null);
        }
       if(temp.equals("无"))
       z1.setText("账号有误,请重新输入!");
    }
  if(e.getSource()==z2)
    { 密码=z2.getText();
      temp="验证密码,"+登陆帐号+","+密码;
      out.writeUTF(temp);
      temp=in.readUTF();
      if(temp.equals("正确"))
       card.show(panel,"4");
      if(temp.equals("错误"))
       {z2.setText("");
        z2.setBackground(Color.black);
        z2.setForeground(Color.white);
       }
    }
  if(e.getSource()==z4)
    {float x;
     try{x=Float.parseFloat(z4.getText());
         temp="取款,"+登陆帐号+","+String.valueOf(x);
         out.writeUTF(temp);
         temp=in.readUTF();
     if(temp.equals("成功"))
       {card.show(panel,"7");
       }
     if(temp.equals("失败"))
       card.show(panel,"8");
       }
     
    catch(NumberFormatException e1){z4.setText("无效字符");}
    }
  if(e.getSource()==z5)
    { 转帐号=z5.getText();
      temp="验证帐号,"+转帐号;
      out.writeUTF(temp);
      temp=in.readUTF();
      if(temp.equals("有"))
       {z6.setEnabled(true);
        z6.setText("");
       }
      if(temp.equals("无"))
       card.show(panel,"12");
    }
  if(e.getSource()==z6)
    {float y;
     try{y=Float.parseFloat(z6.getText());
     temp="转帐,"+登陆帐号+","+String.valueOf(y)+","+转帐号;
     out.writeUTF(temp);
     temp=in.readUTF();
     if(temp.equals("成功"))
       {card.show(panel,"10");
       }
     if(temp.equals("失败"))
       card.show(panel,"11");
        }
    catch(NumberFormatException e2){z6.setText("无效字符");}
    }
  if(e.getSource()==z7)
    {if(z7.getText().equals(密码))
       {z9.setText(null);
        z9.setEditable(false);
        z9.setText("不可编辑状态");
        card.show(panel,"15");
        z8.setText(null);
       }
     else
       card.show(panel,"14");
    }
  if(e.getSource()==z8)
    {新密码=z8.getText();
     z9.setEditable(true);
     z9.setText(null);
     z9.setEchoChar('*');
    }
  if(e.getSource()==z9)
    {if(新密码.equals(z9.getText()))
       {temp="修改密码,"+登陆帐号+","+新密码;
        out.writeUTF(temp);
        temp=in.readUTF();
        if(temp.equals("成功"))
          {card.show(panel,"16");
           密码=新密码;
          }
        }
     else
       card.show(panel,"17");
    }
 }
 catch(Exception ee){}
}
}    

⌨️ 快捷键说明

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