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

📄 modifypass.java

📁 聊天系统。1、聊天 2、传文件 3、多人聊天
💻 JAVA
字号:
package com.client ;

import java.io.* ;
import java.net.* ;
import java.sql.* ;
import javax.swing.* ;
import java.awt.event.*;
import java.awt.* ;
import java.util.*;

public class ModifyPass extends JFrame implements ActionListener{
	private Socket s ;
	private String u ;
	
	public void setSocket(Socket s , String u ){
		this.s = s ;
		this.u = u ;
	}
	
	JPasswordField t_pass = new JPasswordField() ;
	JPasswordField t_rpass = new JPasswordField() ;

	ModifyPass(){
		this.setSize(300 , 200) ;
		
		JLabel l_pass = new JLabel("新密码") ;
		JLabel l_rpass = new JLabel("确认新密码") ;
		JButton b_modify = new JButton("修改") ;
		b_modify.addActionListener(this) ;
		JPanel p1 = new JPanel() ;
		p1.setLayout(new GridLayout(2 , 2)) ;
		p1.add(l_pass) ;
		p1.add(t_pass) ;
		p1.add(l_rpass) ;
		p1.add(t_rpass) ;
		
		JPanel p2 = new JPanel() ;
		p2.setLayout(new FlowLayout()) ;
		p2.add(b_modify) ;
		
		this.setLayout(new BorderLayout()) ;
		this.add(p1 , BorderLayout.CENTER) ;
		this.add(p2 , BorderLayout.SOUTH) ;
		
		this.setVisible(true) ;
	}

	public void actionPerformed(ActionEvent e) {
		if(e.getActionCommand().equals("修改")){
			if(!t_pass.getText().equals(t_rpass.getText())){
				javax.swing.JOptionPane op = new JOptionPane() ;
				op.showMessageDialog(this , "密码不一致,请重新输入!") ;
				t_pass.setText("") ;
				t_rpass.setText("") ;
			}else{
				try {
					OutputStream os = s.getOutputStream() ;
					OutputStreamWriter osw = new OutputStreamWriter(os) ;
					PrintWriter pw = new PrintWriter(osw , true) ;
					
					pw.println("modifypass%"+u+"%"+t_pass.getText()) ; 
			    }
			    catch (Exception ex) {
			    	
			    }
			}
		}
	}
}

⌨️ 快捷键说明

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