java修改密码的界面设计代码(java输入框代码)

http://www.itjxue.com  2023-02-02 00:04  来源:未知  点击次数: 

求大神~~~java代码 关于ATM的 修改密码的 在下面代码里面加就行

代码不完整,还有几个类

public?class?ATMChangePass?extends?JFrame?{

????private?JPanel?contentPane;

????private?JPasswordField?txtOldPass,?txtNewPass1,?txtNewPass2;

????private?String?user;

????private?Zhujiemian?owner;

????public?ATMChangePass(Zhujiemian?owner,?String?user)?{

????????super("修改密码");

????????this.user=user;

????????this.owner=owner;

????????setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

????????setBounds(100,?100,?450,?300);

????????contentPane?=?new?JPanel();

????????contentPane.setBorder(new?EmptyBorder(5,?5,?5,?5));

????????setContentPane(contentPane);

????????contentPane.setLayout(null);

????????

????????JLabel?label?=?new?JLabel("\u8BF7\u8F93\u5165\u65E7\u5BC6\u7801");

????????label.setBounds(10,?43,?155,?33);

????????contentPane.add(label);

????????

????????JLabel?label_1?=?new?JLabel("\u8BF7\u8F93\u5165\u65B0\u5BC6\u7801");

????????label_1.setBounds(10,?113,?155,?33);

????????contentPane.add(label_1);

????????

????????JLabel?label_2?=?new?JLabel("\u8BF7\u518D\u6B21\u8F93\u5165\u65B0\u5BC6\u7801");

????????label_2.setBounds(10,?179,?155,?39);

????????contentPane.add(label_2);

????????

????????txtOldPass?=?new?JPasswordField();

????????txtOldPass.setColumns(10);

????????txtOldPass.setBounds(214,?49,?118,?21);

????????contentPane.add(txtOldPass);

????????

????????txtNewPass1?=?new?JPasswordField();

????????txtNewPass1.setColumns(10);

????????txtNewPass1.setBounds(214,?119,?118,?21);

????????contentPane.add(txtNewPass1);

????????

????????txtNewPass2?=?new?JPasswordField();

????????txtNewPass2.setColumns(10);

????????txtNewPass2.setBounds(214,?188,?118,?21);

????????contentPane.add(txtNewPass2);

????????

????????JButton?button?=?new?JButton("修改");

????????button.addMouseListener(new?MouseAdapter()?{

????????????@Override

????????????public?void?mouseClicked(MouseEvent?arg0)?{

????????????????doChangePass();

????????????}

????????});

????????button.setBounds(74,?228,?93,?23);

????????contentPane.add(button);

????????

????????JButton?button_1?=?new?JButton("返回");

????????button_1.addMouseListener(new?MouseAdapter()?{

????????????@Override

????????????public?void?mouseClicked(MouseEvent?arg0)?{

????????????????dispose();

????????????????ATMChangePass.this.owner.setVisible(true);

????????????}

????????});

????????button_1.setBounds(239,?228,?93,?23);

????????contentPane.add(button_1);

????????setVisible(true);

????}

????private?void?doChangePass(){

????????if(txtOldPass.getText().length()6){

????????????JOptionPane.showMessageDialog(this,?"原密码不正确!",?getTitle(),?JOptionPane.WARNING_MESSAGE);

????????????return;

????????}

????????if(txtNewPass2.getText().length()6){

????????????JOptionPane.showMessageDialog(this,?"新密码不正确!",?getTitle(),?JOptionPane.WARNING_MESSAGE);

????????????return;

????????}

????????if(!txtNewPass1.getText().equals(txtNewPass2.getText())){

????????????JOptionPane.showMessageDialog(this,?"新密码不对应!",?getTitle(),?JOptionPane.WARNING_MESSAGE);

????????????return;

????????}

????????

????????JOptionPane.showMessageDialog(this,?"修改成功!");

????????dispose();

????}

????public?static?void?main(String?args[])throws?Exception{

????????new?ATMChangePass(null,?"user1");

????}

}

JAVA设计GUI登陆界面上,有修改密码的Button,对于修改密码的源代码?

你肯定用数据库了吧,过程很简单啊,就是把你修改以后的值覆盖到数据库中就行了。不过覆盖前最后检验一下新密码是否合法

用Java设计一个登录页面,不用连接数据库,只要把用户和密码信息存放在文本里面,怎样设计代码???

/* Main.java

*

* Created on __DATE__, __TIME__

*/

import javax.swing.JOptionPane;

/**

*

* @author __USER__

*/

public class Main extends javax.swing.JFrame {

/** Creates new form Main */

public Main() {

initComponents();

}

/** This method is called from within the constructor to

* initialize the form.

* WARNING: Do NOT modify this code. The content of this method is

* always regenerated by the Form Editor.

*/

//GEN-BEGIN:initComponents

// editor-fold defaultstate="collapsed" desc="Generated Code"

private void initComponents() {

jPanel1 = new javax.swing.JPanel(); //标签

jLabel1 = new javax.swing.JLabel();

jLabel2 = new javax.swing.JLabel();

jLabel3 = new javax.swing.JLabel();

jButton1 = new javax.swing.JButton(); //登录按钮

jButton2 = new javax.swing.JButton(); //

jTextField1 = new javax.swing.JTextField(); //文本框

jTextField2 = new javax.swing.JTextField();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); //关闭时的操作,即退出程序

setTitle("登录界面"); //设置标题:欢迎使用股票管理系统

setResizable(false); //设置窗口不可调节大小

jLabel1.setFont(new java.awt.Font("微软雅黑", 0, 18)); //设置标签的字体

jLabel1

.setText("您好,请输入信息");

jLabel2.setText("用户名");

jLabel3.setText("用户密码");

jButton1.setText("登录");

jButton1.addActionListener(new java.awt.event.ActionListener() { //采用匿名内部类来实现按钮监听功能

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton1ActionPerformed(evt);

}

});

jButton2.setText("退出");

jButton2.addActionListener(new java.awt.event.ActionListener() { //同上

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton2ActionPerformed(evt);

}

});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout( //层次布局管理器,下面n长的代码,就是设置位置,自己看吧,呵呵,这个必须的,就不多写了

jPanel1);

jPanel1.setLayout(jPanel1Layout);

jPanel1Layout

.setHorizontalGroup(jPanel1Layout

.createParallelGroup(

javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(

javax.swing.GroupLayout.Alignment.TRAILING,

jPanel1Layout.createSequentialGroup()

.addContainerGap(159, Short.MAX_VALUE)

.addComponent(jLabel1).addGap(140, 140,

140))

.addGroup(

jPanel1Layout

.createSequentialGroup()

.addGap(110, 110, 110)

.addGroup(

jPanel1Layout

.createParallelGroup(

javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jLabel2)

.addComponent(jLabel3))

.addGap(54, 54, 54)

.addGroup(

jPanel1Layout

.createParallelGroup(

javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(

jPanel1Layout

.createSequentialGroup()

.addComponent(

jTextField2,

javax.swing.GroupLayout.DEFAULT_SIZE,

191,

Short.MAX_VALUE)

.addGap(

112,

112,

112))

.addGroup(

jPanel1Layout

.createSequentialGroup()

.addComponent(

jTextField1,

javax.swing.GroupLayout.PREFERRED_SIZE,

191,

javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap())))

.addGroup(

jPanel1Layout

.createSequentialGroup()

.addGap(141, 141, 141)

.addComponent(

jButton1,

javax.swing.GroupLayout.PREFERRED_SIZE,

68,

javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(89, 89, 89)

.addComponent(

jButton2,

javax.swing.GroupLayout.PREFERRED_SIZE,

72,

javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(145, Short.MAX_VALUE)));

jPanel1Layout

.setVerticalGroup(jPanel1Layout

.createParallelGroup(

javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(

jPanel1Layout

.createSequentialGroup()

.addContainerGap()

.addComponent(jLabel1)

.addGap(55, 55, 55)

.addGroup(

jPanel1Layout

.createParallelGroup(

javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jLabel2)

.addComponent(

jTextField1,

javax.swing.GroupLayout.PREFERRED_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE,

javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(41, 41, 41)

.addGroup(

jPanel1Layout

.createParallelGroup(

javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel3)

.addComponent(

jTextField2,

javax.swing.GroupLayout.PREFERRED_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE,

javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(43, 43, 43)

.addGroup(

jPanel1Layout

.createParallelGroup(

javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(

jButton1,

javax.swing.GroupLayout.PREFERRED_SIZE,

33,

javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(

jButton2,

javax.swing.GroupLayout.PREFERRED_SIZE,

33,

javax.swing.GroupLayout.PREFERRED_SIZE))

.addContainerGap(48, Short.MAX_VALUE)));

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(

getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(layout.createParallelGroup(

javax.swing.GroupLayout.Alignment.LEADING).addGroup(

layout.createSequentialGroup().addContainerGap().addComponent(

jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addContainerGap()));

layout.setVerticalGroup(layout.createParallelGroup(

javax.swing.GroupLayout.Alignment.LEADING).addGroup(

layout.createSequentialGroup().addContainerGap().addComponent(

jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE,

javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,

Short.MAX_VALUE)));

pack();

setLocationRelativeTo(null); //居中

}// /editor-fold

//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { //事件处理,不建议这样做

// TODO add your handling code here:

String name = this.jTextField1.getText().trim(); //获得用户名,去空格

String password = this.jTextField2.getText().trim(); //获得密码,去空格

if (name.equals("admin") password.equals("123456")) { //如果符合条件.....其实这里应该去和数据库关联,这是死代码

// Showinformation sf=new Showinformation(); //我估计是另外一个框架,就是登录成功之后的框架

// sf.setVisible(true);

// sf.show(); //这个方法就直接秒杀,不用了,因为sf.setVisible(true)已经被调用了,这里就多次一举了

} else { //用户名或者密码验证失败

JOptionPane.showMessageDialog(this, "用户名或者密码错误啦~", "提示", //提示框

JOptionPane.INFORMATION_MESSAGE);

this.jTextField1.setText(""); //清空输入框

this.jTextField2.setText("");

}

}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { //事件处理,其实可以将jButton1ActionPerformed放在一起处理,只要获得按钮的标签内容 (JButton)(evt.getSuorse()).getText()就做对比就ko了

// TODO add your handling code here:

System.exit(0);

}

/**

* @param args the command line arguments

*/

public static void main(String args[]) {

java.awt.EventQueue.invokeLater(new Runnable() { //好方法,呵呵使用该方式的原因是:awt是单线程模式的,所有awt的组件只能在(推荐方式)事件处理线程中访问,从而保证组件状态的可确定性。java核心编程技术中每个实例基本都用到了

public void run() {

new Main().setVisible(true);

}

});

}

//GEN-BEGIN:variables

// Variables declaration - do not modify

private javax.swing.JButton jButton1;

private javax.swing.JButton jButton2;

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel2;

private javax.swing.JLabel jLabel3;

private javax.swing.JPanel jPanel1;

private javax.swing.JTextField jTextField1;

private javax.swing.JTextField jTextField2;}

// End of variables declaration//GEN-END:variables

你修改一下吧,从记事本获得用户名判断一下就行了

用jsp java做一个修改登录密码,有下面的代码

首先,form表单必须的,是用来输入用户名和密码,brform表单 action="%=basePath %Admin.shtml" method="post",br主要指明的是请求的路径,请求的方式,post.bronSubmit="return checkPWD()"的目的就是在点击提交的时候执行的操作,。br成功的话就跳转到action所指定的路径去。不成功的话就是还在当前页。br/HEADbr%brString message = (String)request.getAttribute("message");brif(message == null){brmessage = "";br}brif (!message.trim().equals("")){brout.println("script language='javascript'");brout.println("alert('"+message+"');");brout.println("/script");br}brrequest.removeAttribute("message");br%br%brString username=(String)session.getAttribute("user");brif(username==null){brresponse.sendRedirect(basePath+"/error.jsp");br}brelse{brList list=(List)session.getAttribute("list");br%br从session里面获取userName的值,然后就是判断,如果是空的话就跳转到错误的页面,还有如果请求的信息如果有的话就弹出请求的信息的内容!!!

java 修改登陆密码 代码

你这个登陆程序哪来的修改按钮啊,只有确定和退出两个按钮嘛.

你这登陆用户名是:sdd 密码是:123 而且要程序中已经定死了.这一句:if ((name.equals("sdd")) (passWord.equals("123")))说的.

你如果想添加一个修改用户名和密码的按钮就必须用一个另外的文件进行保存,当然用数据库就更好了.而你这个没必要改,因为没有永久存贮的文件,即使你改了密码,当你下次再运行时密码又被重新初始化了.

JAVA中怎么更改密码?如下代码.求帮忙调试.实现功能4修改密码的功能

你要想让程序记住你的修改结果是不可能的,应为你只要退出这个程序,所有的变量都就被清理了。当你再次重新运行程序时,所有的变量又被从新初始化赋值。你要想验证你的密码是不是被修改就得找那个保存文件的代码。将你的修改结果保存起来。要不然你是看不到结果的。。或者你就把你的那些写入到数据库中。然后在查询数据库。

你要是想修改本程序的。你这个程序中的密码是123.、那你就弄个输入程序。然后这个123替换掉不就行了嘛。if (name1.equals("xiaoming") pwd1.equals("123")) 。如果你是想让显示出来。当完成String p = scan.next();这句后,你把p的值就得到了。打印出来就可以了啊

(责任编辑:IT教学网)

更多