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

📄 password_change_panel.java~10~

📁 javaGUI编写的人事管理系统(毕业学生答辩可参考)
💻 JAVA~10~
字号:
package project;

import javax.swing.*;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.SystemColor;
import java.awt.Component;
import java.awt.Color;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2006</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class Password_change_panel
    extends JPanel implements All_panel {
  JFrame mainframe = null;

  public Password_change_panel(JFrame mainframe) {
    this.mainframe = mainframe;
    try {
      jbInit();
      this.setLocation(0,0);
     // setPanelPosOnDesktop(mainframe);
    }
    catch (Exception ex) {
      ex.printStackTrace();
    }
  }

  private void jbInit() throws Exception {
    this.setLayout(null);
    this.setSize(400, 280);
    jLabel1.setHorizontalAlignment(SwingConstants.LEFT);
    jLabel1.setText("请输入密码:");
    jLabel1.setBounds(new Rectangle(45, 14, 101, 27));
    jLabel2.setHorizontalAlignment(SwingConstants.LEFT);
    jLabel2.setText("请输入新密码:");
    jLabel2.setBounds(new Rectangle(45, 56, 123, 27));
    jLabel3.setToolTipText("");
    jLabel3.setHorizontalAlignment(SwingConstants.LEFT);
    jLabel3.setText("请再输入一遍新密码:");
    jLabel3.setBounds(new Rectangle(45, 98, 128, 27));
    old_text.setBounds(new Rectangle(180, 13, 168, 28));
    new_text1.setBounds(new Rectangle(180, 56, 168, 28));
    new_text2.setBounds(new Rectangle(180, 99, 168, 28));
    ok_btn.setBackground(new Color(233, 236, 216));
    ok_btn.setBounds(new Rectangle(41, 174, 89, 33));
    ok_btn.setOpaque(false);
    ok_btn.setText("确  定");
    ok_btn.addActionListener(new Password_change_panel_ok_btn_actionAdapter(this));
    reset.setBounds(new Rectangle(156, 174, 89, 33));
    reset.setOpaque(false);
    reset.setText("重  置");
    reset.addActionListener(new Password_change_panel_reset_actionAdapter(this));
    cancel_btn.setBounds(new Rectangle(271, 174, 89, 33));
    cancel_btn.setOpaque(false);
    cancel_btn.setText("取  消");
    cancel_btn.addActionListener(new
                                 Password_change_panel_cancel_btn_actionAdapter(this));
    this.setBackground(SystemColor.control);
    this.add(jLabel1);
    this.add(jLabel3);
    this.add(jLabel2);
    this.add(new_text2);
    this.add(old_text);
    this.add(new_text1);
    this.add(ok_btn);
    this.add(reset);
    this.add(cancel_btn);
  }

  public void setPanelPosOnDesktop(JFrame frame) {
    this.setLocation( (frame.getSize().width - this.getSize().width) / 2,
                     (frame.getSize().height - this.getSize().height) / 2);
  }

  public void closeCurrentPanel(JFrame frame) {

    ((Frame1)frame).remove_panel();

  }

  public void set_focus() {
    old_text.requestFocus();
  }

  JLabel jLabel1 = new JLabel();
  JLabel jLabel2 = new JLabel();
  JLabel jLabel3 = new JLabel();
  JPasswordField old_text = new JPasswordField();
  JPasswordField new_text1 = new JPasswordField();
  JPasswordField new_text2 = new JPasswordField();
  JButton ok_btn = new JButton();
  JButton reset = new JButton();
  JButton cancel_btn = new JButton();
  public void cancel_btn_actionPerformed(ActionEvent e) {
    closeCurrentPanel(mainframe);
  }

  public void reset_actionPerformed(ActionEvent e) {
    old_text.setText("");
    new_text1.setText("");
    new_text2.setText("");
    old_text.requestFocus();
  }

  public void ok_btn_actionPerformed(ActionEvent e) {
   // Password_change pwd_change = new Password_change(this.mainframe, this);
    String old_pwd = new String(old_text.getPassword());
    String new_pwd1 = new String(new_text1.getPassword());
    String new_pwd2 = new String(new_text2.getPassword());
    int res = 0;//pwd_change.update_password(old_pwd, new_pwd1, new_pwd2);
    switch (res) {
      case 0:
        old_text.selectAll();
        old_text.requestFocus();
        break;
      case 1:
        new_text1.selectAll();
        new_text1.requestFocus();
        break;
      case 2:
        new_text2.selectAll();
        new_text2.requestFocus();
        break;
      case 3:
        new_text2.setText("");
        new_text1.selectAll();
        new_text1.requestFocus();
        break;
      case 4:
        old_text.selectAll();
        old_text.requestFocus();
        break;
      case 5:
        this.closeCurrentPanel(this.mainframe);
        break;
      case 6:
        old_text.setText("");
        new_text1.setText("");
        new_text2.setText("");
        old_text.requestFocus();
        break;
      case -1:
        old_text.setText("");
        new_text1.setText("");
        new_text2.setText("");
        old_text.requestFocus();

    }
  }
}

class Password_change_panel_ok_btn_actionAdapter
    implements ActionListener {
  private Password_change_panel adaptee;
  Password_change_panel_ok_btn_actionAdapter(Password_change_panel adaptee) {
    this.adaptee = adaptee;
  }

  public void actionPerformed(ActionEvent e) {
    adaptee.ok_btn_actionPerformed(e);
  }
}

class Password_change_panel_reset_actionAdapter
    implements ActionListener {
  private Password_change_panel adaptee;
  Password_change_panel_reset_actionAdapter(Password_change_panel adaptee) {
    this.adaptee = adaptee;
  }

  public void actionPerformed(ActionEvent e) {
    adaptee.reset_actionPerformed(e);
  }
}

class Password_change_panel_cancel_btn_actionAdapter
    implements ActionListener {
  private Password_change_panel adaptee;
  Password_change_panel_cancel_btn_actionAdapter(Password_change_panel adaptee) {
    this.adaptee = adaptee;
  }

  public void actionPerformed(ActionEvent e) {
    adaptee.cancel_btn_actionPerformed(e);
  }
}

⌨️ 快捷键说明

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