java编写一个更改密码校验程序,有两个密码框,一个用于输入新密码,另一个请输入确认密码……
java编写一个更改密码校验程序,有两个密码框,一个用于输入新密码,另一个请输入确认密码,如果两个密码框中的内容一致,则“确认”按钮后弹出消息框“修改成功!”否则弹出警告...
java编写一个更改密码校验程序,有两个密码框,一个用于输入新密码,另一个请输入确认密码,如果两个密码框中的内容一致,则“确认”按钮后弹出消息框“修改成功!”否则弹出警告框“失败,请确认密码!”
展开
展开全部
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
public class keyPassword extends JDialog{
private JLabel jl1 = new JLabel("password:");
private JLabel jl2 = new JLabel("确认密码");
private JTextField pwd1 = new JTextField(18);
private JTextField pwd2 = new JTextField(18);
private JButton sure = new JButton("确定");
private JPanel jp1 = new JPanel();
public keyPassword(){
setVisible(true);
setSize(300, 150);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
jp1.add(jl1);
jp1.add(pwd1);
jp1.add(jl2);
jp1.add(pwd2);
jp1.add(sure);
sure.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
String str = pwd1.getText();
String str2 = pwd2.getText();
if(str.equals("") || str2.equals("")){
JOptionPane.showMessageDialog(null, "不能为空");
}else if(str.equals(str2)){
JOptionPane.showMessageDialog(null, "两次密码相同!");
}else{
JOptionPane.showMessageDialog(null, "两次密码不相同!");
}
}
});
add(jp1);
}
public static void main(String[] args) {
new keyPassword();
}
}
最新版本:有什么问题可以联系我,
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
public class keyPassword extends JDialog{
private JLabel jl1 = new JLabel("password:");
private JLabel jl2 = new JLabel("确认密码");
private JPasswordField jpf = new JPasswordField(18);
private JPasswordField jpf2 = new JPasswordField(18);
private JButton sure = new JButton("确定");
private JPanel jp1 = new JPanel();
public keyPassword(){
setVisible(true);
setSize(300, 150);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
jp1.add(jl1);
jp1.add(jpf);
jp1.add(jl2);
jp1.add(jpf2);
jp1.add(sure);
sure.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
char[] str_ = jpf.getPassword();
String str=String.copyValueOf(str_);
char[] str2_ = jpf2.getPassword();
String str2 =String.copyValueOf(str2_);
if(str.equals("") || str2.equals("")){
JOptionPane.showMessageDialog(null, "不能为空");
}else if(str.equals(str2)){
JOptionPane.showMessageDialog(null, "两次密码相同!");
}else{
JOptionPane.showMessageDialog(null, "两次密码不相同!");
}
}
});
add(jp1);
}
public static void main(String[] args) {
new keyPassword();
}
}
展开全部
import java.util.Scanner;
public class Test
{
/**
* @param args
*/
public static void main(String[] args)
{
// TODO Auto-generated method stub
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
System.out.println("请输入新密码:");
String newPassword1 = input.next();
System.out.println("请再次输入密码:");
String newPassword2= input.next();
if(newPassword1.equals(newPassword2))
{
System.out.println("密码修改成功!");
}
else
{
System.out.println("两次密码不一致");
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<html>
<head>
<title>
修改密码
</title>
</head>
<script>
function eq_yes_or_no(){
var pass1=document.getElementById("psd1").value;
var pass2=document.getElementById("psd2").value;
if(pass1==pass2){
alert("修改成功!");
}else{
alert("密码不一样!");
}
}
</script>
<body>
<input type="text" id="psd1" value=""/>
<input type="text" id="psd2" value=""/>
<input type="button" value="确认" onclick="eq_yes_or_no()"/>
</body>
</html>
<head>
<title>
修改密码
</title>
</head>
<script>
function eq_yes_or_no(){
var pass1=document.getElementById("psd1").value;
var pass2=document.getElementById("psd2").value;
if(pass1==pass2){
alert("修改成功!");
}else{
alert("密码不一样!");
}
}
</script>
<body>
<input type="text" id="psd1" value=""/>
<input type="text" id="psd2" value=""/>
<input type="button" value="确认" onclick="eq_yes_or_no()"/>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class changeTitle extends JFrame implements ActionListener {
/**
*
*/
private static final long serialVersionUID = 1L;
public static final int width = 250;
public static final int height = 150;
JTextField text1;
JTextField text2;
JLabel la1;
JPanel la11;
JLabel la2;
JPanel la22;
JButton jbn;
changeTitle(){
setTitle("hello");
setSize(width, height);
setLayout(new FlowLayout());
text1=new JPasswordField(15);
text2=new JPasswordField(15);
la11=new JPanel();
la22=new JPanel();
la1=new JLabel("输新密码:");
la2=new JLabel("确认密码:");
jbn=new JButton("修改密码");
la11.add(la1);
la11.add(text1);
la22.add(la2);
la22.add(text2);
add(la11);
add(la22);
add(jbn);
jbn.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==jbn){
if(text1.getText().equals(text2.getText())){
JOptionPane.showMessageDialog(null, "修改成功", "提示", JOptionPane.INFORMATION_MESSAGE);
}else{
JOptionPane.showMessageDialog(null, "两次输入不相同", "提示", JOptionPane.ERROR_MESSAGE);
}
}
}
public static void main(String[] args ){
changeTitle changetitle=new changeTitle();
changetitle.setVisible(true);
changetitle.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class changeTitle extends JFrame implements ActionListener {
/**
*
*/
private static final long serialVersionUID = 1L;
public static final int width = 250;
public static final int height = 150;
JTextField text1;
JTextField text2;
JLabel la1;
JPanel la11;
JLabel la2;
JPanel la22;
JButton jbn;
changeTitle(){
setTitle("hello");
setSize(width, height);
setLayout(new FlowLayout());
text1=new JPasswordField(15);
text2=new JPasswordField(15);
la11=new JPanel();
la22=new JPanel();
la1=new JLabel("输新密码:");
la2=new JLabel("确认密码:");
jbn=new JButton("修改密码");
la11.add(la1);
la11.add(text1);
la22.add(la2);
la22.add(text2);
add(la11);
add(la22);
add(jbn);
jbn.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==jbn){
if(text1.getText().equals(text2.getText())){
JOptionPane.showMessageDialog(null, "修改成功", "提示", JOptionPane.INFORMATION_MESSAGE);
}else{
JOptionPane.showMessageDialog(null, "两次输入不相同", "提示", JOptionPane.ERROR_MESSAGE);
}
}
}
public static void main(String[] args ){
changeTitle changetitle=new changeTitle();
changetitle.setVisible(true);
changetitle.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询