[Java] 忘记密码界面 →→→→→进入此内容的聊天室

来自 , 2019-04-03, 写在 Java, 查看 124 次.
URL http://www.code666.cn/view/acf4b89d
  1. //此类是找回密码
  2. package com.view;
  3.  
  4. import java.awt.Color;
  5. /**
  6.  * 找回密码
  7.  * @author wu2xin
  8.  *
  9.  */
  10. public class InTo_Forget extends JFrame implements ActionListener{
  11.  
  12.         /**
  13.          * 成员变量
  14.          */
  15.         private static final long serialVersionUID = 1L;
  16.         private JPanel contentPane;
  17.         private JPanel panel;
  18.         private JLabel nameLab,alertLab,alertImg;
  19.         private JTextField nameTex;
  20.         private JTextField emailTex;
  21.         private JButton delBut;
  22.         private JScrollPane scrollPane;
  23.         private JLabel alert;
  24.         private JTextArea textArea;
  25.         private JButton blackBut;
  26.         private JCheckBox nameCheck,emailCheck;
  27.         private JButton lookBtu;
  28.         private JLabel topImage;
  29.  
  30.         /**
  31.          * new 出来新窗口
  32.          */
  33.         public static void main(String[] args) {
  34.                
  35.                 InTo_Forget frame = new InTo_Forget();
  36.                 frame.setVisible(true);
  37.        
  38.         }
  39.  
  40.         /**
  41.          * 构造初始化
  42.          */
  43.         public InTo_Forget() {
  44.                 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  45.                 this.setUndecorated(true);//去掉窗口的装饰
  46.                 this.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);////设置为简单对话窗口
  47.                 this.setTitle("找回密码");
  48.                 this.setSize(694, 498);
  49.                 this.setLocationRelativeTo(null);
  50.                 contentPane = new JPanel();
  51.                 contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  52.                 setContentPane(contentPane);
  53.                 contentPane.setLayout(null);
  54.                
  55.                 alertImg=new JLabel(new ImageIcon("image/search1.gif"));
  56.                 alertImg.setBounds(0, 21, 60, 45);
  57.                 contentPane.add(alertImg);
  58.                
  59.                 alertLab =new JLabel("找回密码");
  60.                 alertLab.setFont(new Font("楷体", Font.BOLD, 20));
  61.                 alertLab.setLocation(65, 21);
  62.                 alertLab.setSize(113, 30);
  63.                 contentPane.add(alertLab);
  64.                
  65.                 topImage = new JLabel(new ImageIcon("image/找回密码插景图.jpg"));
  66.                 topImage.setBounds(376, 0, 307, 114);
  67.                 contentPane.add(topImage);
  68.                
  69.                 /**
  70.                  *操作 面板
  71.                  */
  72.                 panel = new JPanel();
  73.                 panel.setOpaque(false);//透明
  74.                 TitledBorder tb=new TitledBorder("欢迎找回密码");
  75.                 tb.setTitleFont(new Font("陈代明硬笔体", Font.PLAIN, 20));
  76.                 tb.setTitleColor(Color.blue);
  77.                 panel.setBorder(tb);//在Jpanel上打几个标题
  78.                 panel.setBounds(0, 104, 684, 298);
  79.                 contentPane.add(panel);
  80.                 panel.setLayout(null);
  81.                
  82.                 nameCheck = new JCheckBox("按用户名");
  83.                 nameCheck.setBounds(3, 33, 82, 30);
  84.                 nameCheck.setOpaque(false);//透明
  85.                 nameCheck.addActionListener(this);//监听1
  86.                 panel.add(nameCheck);
  87.                
  88.                 emailCheck = new JCheckBox("按邮箱");
  89.                 emailCheck.setBounds(3, 105, 82, 30);
  90.                 emailCheck.setOpaque(false);//透明
  91.                 emailCheck.addActionListener(this);//监听1
  92.                 panel.add(emailCheck);
  93.                
  94.                 nameLab = new JLabel("用户名:");
  95.                 nameLab.setForeground(Color.BLUE);
  96.                 nameLab.setFont(new Font("楷体", Font.BOLD, 16));
  97.                 nameLab.setHorizontalAlignment(SwingConstants.RIGHT);
  98.                 nameLab.setBounds(27, 69, 73, 30);
  99.                 panel.add(nameLab);
  100.                
  101.                 nameTex = new JTextField();
  102.                 nameTex.setBackground(Color.WHITE);
  103.                 nameTex.setEditable(false);
  104.                 nameTex.setBounds(110, 68, 123, 30);
  105.                 panel.add(nameTex);
  106.                 nameTex.setColumns(10);
  107.                
  108.                 JLabel emailLab = new JLabel("邮箱:");
  109.                 emailLab.setForeground(Color.BLUE);
  110.                 emailLab.setFont(new Font("楷体", Font.BOLD, 16));
  111.                 emailLab.setHorizontalAlignment(SwingConstants.RIGHT);
  112.                 emailLab.setBounds(27, 141, 73, 30);
  113.                 panel.add(emailLab);
  114.                
  115.                 emailTex = new JTextField();
  116.                 emailTex.setBackground(Color.WHITE);
  117.                 emailTex.setEditable(false);
  118.                 emailTex.setColumns(10);
  119.                 emailTex.setBounds(110, 141, 123, 30);
  120.                 panel.add(emailTex);
  121.                
  122.                 lookBtu= new JButton("查询");
  123.                 lookBtu.setBounds(27, 226, 71, 30);
  124.                 lookBtu.addActionListener(this);//监听1
  125.                 panel.add(lookBtu);
  126.                
  127.                 delBut = new JButton("清空");
  128.                 delBut.setBounds(162, 226, 71, 30);
  129.                 delBut.addActionListener(this);//监听1
  130.                 panel.add(delBut);
  131.                
  132.                 scrollPane = new JScrollPane();
  133.                 scrollPane.setBounds(322, 44, 354, 231);
  134.                 panel.add(scrollPane);
  135.                
  136.                 textArea = new JTextArea();
  137.                 scrollPane.setViewportView(textArea);
  138.                
  139.                 alert = new JLabel("信息提示:");
  140.                 alert.setHorizontalAlignment(SwingConstants.RIGHT);
  141.                 alert.setForeground(Color.BLACK);
  142.                 alert.setFont(new Font("楷体", Font.PLAIN, 16));
  143.                 alert.setBounds(263, 10, 82, 30);
  144.                 panel.add(alert);
  145.                
  146.                 blackBut = new JButton("返回主页");
  147.                 blackBut.setBounds(574, 412, 86, 30);
  148.                 blackBut.addActionListener(this);//监听1
  149.                 contentPane.add(blackBut);
  150.                
  151.                 JLabel topImg = new JLabel(new ImageIcon("image/forget.jpg"));
  152.                 topImg.setBounds(0, 0, 686, 498);
  153.                 contentPane.add(topImg);
  154.                
  155.                
  156.                
  157.                 this.setVisible(true);//可见
  158.                
  159.         }
  160. /////////////////////////////////////////////////////////////注册监听器1(普通事件)
  161.         @Override
  162.         public void actionPerformed(ActionEvent de) {
  163.                 // TODO Auto-generated method stub
  164.                 String id=nameTex.getText();
  165.                 //String email=emailTex.getText();
  166.                 AdminModel model=new AdminModel();
  167.                 if(de.getSource()==nameCheck){//用户名单选
  168.                         if(nameCheck.isSelected()){
  169.                                 nameTex.setEditable(true);
  170.                                 emailTex.setEditable(false);
  171.                                 emailCheck.setSelected(false);
  172.                         }else{
  173.                                 nameTex.setEditable(false);
  174.                         }
  175.                 }else if(de.getSource()==emailCheck){//email 单选
  176.                         if(emailCheck.isSelected()){
  177.                                 nameTex.setEditable(false);
  178.                                 nameCheck.setSelected(false);
  179.                                 emailTex.setEditable(true);
  180.                         }
  181.                 }else if(de.getSource()==lookBtu){//查询
  182.                        
  183.                         if(StringUtil.isNotNull(id)){
  184.                                 AdminPoJo pojo=model.getAdmin(Integer.parseInt(id));
  185.                                 if(pojo!=null){
  186.                                         textArea.setText(id+",找回成功!\n\t"+pojo.getName()+"你好,你的密码是:"+pojo.getPassword());
  187.                                 }else{
  188.                                         textArea.setText("对不起,查找失败,没有"+id+"该账号");
  189.                                 }
  190.                         }else{
  191.                                 JOptionPane.showMessageDialog(null, "请选择查询条件");
  192.                         }
  193.                        
  194.                 }else if(de.getSource()==delBut){//撤销
  195.                        
  196.                         nameTex.setText("");
  197.                         emailTex.setText("");
  198.                         textArea.setText("");
  199.  
  200.                 }else if(de.getSource()==blackBut){//返回登录主界面
  201.                         new InTo();
  202.                         this.dispose();
  203.                 }
  204.                
  205.         }
  206. }
  207.  

回复 "忘记密码界面"

这儿你可以回复上面这条便签

captcha