[project practice] write a QQ like interface chat small project in Java, which can chat online!

Spiderman can't fly 2021-01-23 17:55:46
project practice write qq interface


1. Function realization

1. Modify the function ( password 、 nickname 、 Individuality signature )

2. Add buddy 、 Delete friends

3. Single chat function

4. Determine if your friends are online

2. Module partition

 picture

==

3. Knowledge used

  • netty
  • swing
  • Set and other synchronous blocking queues synchronousQueue
  • database MySQL Medium CRUD
  • C3p0 Connection pool
  • JSON character string

==

4. Part of the code implementation

1.nettyController.java

  • Received a message from the client , And dao Layers interact
  • dao The layer interacts with its database

Change Password

 picture

Add buddy

 picture

From the logic of adding friends, I took a lot of detours, frequent access to the database , This is a very bad thing

package chat.Project.controller;
import chat.Project.bean.information;
import chat.Project.constant.EnMsgType;
import chat.Project.dao.*;
import chat.utils.CacheUtil;
import chat.utils.JsonUtils;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.netty.channel.Channel;
import java.util.ArrayList;
import java.util.Iterator;
public class NettyController {
    private static UserDao userDao = new UserDaoImpl();
    private static informationDao informationDao = new informationDaoImpl();
    private static friendDao friendDao = new friendDaoImpl();
    public static String processing(String message, Channel channel){
        // Parse the message sent by the client
        ObjectNode jsonNodes = JsonUtils.getObjectNode(message);
        String msgtype = jsonNodes.get("msgtype").asText();
        if (EnMsgType.EN_MSG_LOGIN.toString().equals(msgtype)){
            // Login operation
            return loginOperation(jsonNodes,channel);
        }else if (EnMsgType.EN_MSG_MODIFY_SIGNATURE.toString().equals(msgtype)){
            // Modify signature
            return modifySignature(jsonNodes);
        }else if (EnMsgType.EN_MSG_MODIFY_NICKNAME.toString().equals(msgtype)){
            // Modify nickname
            return modifyNickname(jsonNodes);
        }else if (EnMsgType.EN_MSG_GETINFORMATION.toString().equals(msgtype)){
            // Get login information
            return getInformation(jsonNodes);
        }else if (EnMsgType.EN_MSG_VERIFY_PASSWORD.toString().equals(msgtype)){
            // Change the password
            return verifyPasswd(jsonNodes);
        }else if (EnMsgType.EN_MSG_CHAT.toString().equals(msgtype)){
            // Single chat mode
            return SingleChat(jsonNodes);
        }else if (EnMsgType.EN_MSG_GET_ID.toString().equals(msgtype)){
            // obtain id
            return getId(jsonNodes);
        }else if (EnMsgType.EN_MSG_GET_FRIEND.toString().equals(msgtype)){
            // Get a list of friends
            return getFriend(jsonNodes);
        }else if (EnMsgType.EN_MSG_ADD_FRIEND.toString().equals(msgtype)){
            // Add buddy
            return addFriends(jsonNodes);
        }else if (EnMsgType.EN_MSG_DEL_FRIEND.toString().equals(msgtype)){
            // Delete friends
            return delFriend(jsonNodes);
        }else if (EnMsgType.EN_MSG_ACTIVE_STATE.toString().equals(msgtype)){
            // Judge your friend's online status
            return friendIsActive(jsonNodes);
        }
        return "";
    }
    // Judge your friend's online status
    private static String friendIsActive(ObjectNode jsonNodes) {
        int friendId = jsonNodes.get("friendId").asInt();
        ObjectNode objectNode = JsonUtils.getObjectNode();
        objectNode.put("msgtype",EnMsgType.EN_MSG_ACK.toString());
        objectNode.put("srctype",EnMsgType.EN_MSG_ACTIVE_STATE.toString());
        // The client ensures that the user exists independently and is a good friend
        Channel channel = CacheUtil.get(friendId);
        // Judge whether the user is online
        if (channel == null){
            // The user is not online
            objectNode.put("code",200);
        }else {
            // Users are online
            objectNode.put("code",300);
        }
        return objectNode.toString();
    }
    // Add buddy
    private static String delFriend(ObjectNode jsonNodes) {
        Integer friendId = jsonNodes.get("friendId").asInt();
        int userId = jsonNodes.get("id").asInt();
        String localName = jsonNodes.get("localName").asText();
        // Encapsulates the JSON
        ObjectNode objectNode = JsonUtils.getObjectNode();
        objectNode.put("msgtype",EnMsgType.EN_MSG_ACK.toString());
        objectNode.put("srctype",EnMsgType.EN_MSG_DEL_FRIEND.toString());
        objectNode.put("code",200);
        // Verify that there are current friends
        information information = informationDao.getInformation(friendId);
        String friendName = information.getNickname();
        // Check if you have the friend
        boolean exist = friendDao.isExist(friendName,userId);
        if (exist){
            // There is a current friend to delete
            friendDao.delFriend(userId,friendName);
            friendDao.delFriend(friendId,localName);
            objectNode.put("code",300);
        }
        return objectNode.toString();
    }
    // Add buddy
    private static String addFriends(ObjectNode jsonNodes) {
        Integer friendId = jsonNodes.get("friendId").asInt();
        int userId = jsonNodes.get("id").asInt();
        String localName = jsonNodes.get("localName").asText();
        // Verify if there is ID
        boolean exists = userDao.verifyExistFriend(friendId);
        ObjectNode objectNode = JsonUtils.getObjectNode();
        objectNode.put("msgtype",EnMsgType.EN_MSG_ACK.toString());
        objectNode.put("srctype",EnMsgType.EN_MSG_ADD_FRIEND.toString());
        objectNode.put("code",200);
        if(exists){
            // It means that there is this id
            objectNode.put("code",300);
            // Get a friend's nickname
            information information = informationDao.getInformation(friendId);
            String friendNickname = information.getNickname();
            // Add friends     Both corresponding information should be added
            friendDao.addFriends(userId,localName,friendNickname);
            friendDao.addFriends(friendId,friendNickname,localName);
        }
        return objectNode.toString();
    }
    // Get a list of friends
    private static String getFriend(ObjectNode jsonNodes) {
        int uid = jsonNodes.get("uid").asInt();
        // return ArrayLis aggregate
        ArrayList<String> friends = friendDao.getFriends(uid);
        // encapsulation JSON
        ObjectNode objectNode = JsonUtils.getObjectNode();
        objectNode.put("msgtype",EnMsgType.EN_MSG_ACK.toString());
        objectNode.put("srctype",EnMsgType.EN_MSG_GET_FRIEND.toString());
        // Write back to friend aggregate
        Iterator<String> iterator = friends.iterator();
        int i = 0;
        while (iterator.hasNext()){
            objectNode.put("res"+i,iterator.next());
            i++;
        }
        // Record the number of friends
        objectNode.put("count",i);
        return objectNode.toString();
    }
    // obtain id
    private static String getId(ObjectNode jsonNodes) {
        String nickname = jsonNodes.get("nickname").asText();
        information information = informationDao.nicknameGetId(nickname);
        // Of the contact person id
        int uid = information.getUid();
        // encapsulation JSON
        ObjectNode objectNode = JsonUtils.getObjectNode();
        objectNode.put("msgtype",EnMsgType.EN_MSG_ACK.toString());
        objectNode.put("srctype",EnMsgType.EN_MSG_GET_ID.toString());
        objectNode.put("uid",uid);
        return objectNode.toString();
    }
    // Single chat mode
    private static String SingleChat(ObjectNode jsonNodes) {
        int id = jsonNodes.get("id").asInt();
        // according to id stay friend Table to get the login user name
        // encapsulation JSON The data server forwards data
        ObjectNode objectNode = JsonUtils.getObjectNode();
        objectNode.put("msgtype",EnMsgType.EN_MSG_ACK.toString());
        objectNode.put("srctype",EnMsgType.EN_MSG_CHAT.toString());
        // The client ensures that the user exists independently and is a good friend
        Channel channel = CacheUtil.get(id);
        // Judge whether the user is online
        if (channel == null){
            // The user is not online
            objectNode.put("code",200);
        }else{
            // Users are online
            objectNode.put("code",300);
            // forward
            channel.writeAndFlush(jsonNodes.toString());
        }
        return objectNode.toString();
    }
    // Change Password
    private static String verifyPasswd(ObjectNode jsonNodes) {
        int id = jsonNodes.get("id").asInt();
        String oldPasswd = jsonNodes.get("oldPasswd").asText();
        String newPasswd = jsonNodes.get("newPasswd").asText();
        boolean exits = userDao.verifyPassword(oldPasswd, id);
        ObjectNode objectNode = JsonUtils.getObjectNode();
        objectNode.put("msgtype",EnMsgType.EN_MSG_VERIFY_PASSWORD.toString());
        objectNode.put("code",200);
        if (exits){
            // Verify success
            userDao.modifyPasswd(newPasswd,id);
            objectNode.put("code",300);
        }
        return objectNode.toString();
    }
    // pick up information
    private static String getInformation(ObjectNode jsonNodes) {
        int id = jsonNodes.get("id").asInt();
        information information = informationDao.getInformation(id);
        // encapsulation JSON Send back to client
        ObjectNode objectNode = JsonUtils.getObjectNode();
        objectNode.put("msgtype",EnMsgType.EN_MSG_ACK.toString());
        objectNode.put("srctype",EnMsgType.EN_MSG_GETINFORMATION.toString());
        objectNode.put("Nickname",information.getNickname());
        objectNode.put("Signature",information.getSignature());
        return objectNode.toString();
    }
    // Modify nickname
    private static String modifyNickname(ObjectNode jsonNodes) {
        int id = jsonNodes.get("id").asInt();
        String nickname = jsonNodes.get("nickname").asText();
        // For storage
        informationDao.storeNickname(nickname,id);
        return "";
    }
    // Modify signature
    private static String modifySignature(ObjectNode jsonNodes) {
        int id = jsonNodes.get("id").asInt();
        String signature = jsonNodes.get("signature").asText();
        // For storage
        informationDao.storeSignature(signature,id);
        return "";
    }
    // Login operation
    private static String loginOperation(ObjectNode objectNode,Channel channel) {
        int id = objectNode.get("id").asInt();
        String passwd = objectNode.get("passwd").asText();
        // Do database query
        boolean exits = userDao.getInformation(id, passwd);
        ObjectNode jsonNodes = JsonUtils.getObjectNode();
        jsonNodes.put("msgtype",EnMsgType.EN_MSG_ACK.toString());
        jsonNodes.put("srctype",EnMsgType.EN_MSG_LOGIN.toString());
        jsonNodes.put("code",300);
        // Return status code
        if (exits){
            jsonNodes.put("code",200);
            // Add user's online information
            CacheUtil.put(id,channel);
        }
        return jsonNodes.toString();
    }
}

2.ClientHandler.java

The client receives the message returned from the server

According to the returned status code to determine whether the operation is successful

package chat.Project.netty;
import chat.Frame.chat.ChatFrame;
import chat.Frame.chat.linkmen;
import chat.Frame.chat.login;
import chat.Project.constant.EnMsgType;
import chat.util.JsonUtils;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import java.util.concurrent.SynchronousQueue;
public class ClientHandler extends SimpleChannelInboundHandler<String> {
    // Define a synchronous blocking queue status code
    public static SynchronousQueue<Object> queue = new SynchronousQueue<>();
    public static String Nickname;
    public String Signature;
    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, String s) throws Exception {
    }
    // Client receives data
    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        System.out.println(msg);
        // Parse the message sent by the server
        ObjectNode jsonNodes = JsonUtils.getObjectNode((String) msg);
        String msgtype = jsonNodes.get("msgtype").asText();
        if (EnMsgType.EN_MSG_ACK.toString().equals(msgtype)) {
            String srctype = jsonNodes.get("srctype").asText();
            if (EnMsgType.EN_MSG_LOGIN.toString().equals(srctype)) {
                // Login operation
                queue.offer(jsonNodes.get("code").asInt());
            }else if(EnMsgType.EN_MSG_GETINFORMATION.toString().equals(srctype)){
                // Access information
                 Nickname = jsonNodes.get("Nickname").asText();
                 Signature = jsonNodes.get("Signature").asText();
                linkmen.label_1.setText(Nickname);
                linkmen.field.setText(Signature);
            }else if (EnMsgType.EN_MSG_CHAT.toString().equals(srctype)){
                // The sender returns a message
                queue.offer(jsonNodes.get("code").asInt());
            }else if (EnMsgType.EN_MSG_GET_ID.toString().equals(srctype)){
                int uid = jsonNodes.get("uid").asInt();
                queue.offer(uid);
            }else if (EnMsgType.EN_MSG_GET_FRIEND.toString().equals(srctype)){
                // Get the login user's friends
                int count = jsonNodes.get("count").asInt();
                login.friend = new String[count];
                for ( int i = 0;i<count;i++){
                    login.friend[i] = jsonNodes.get("res"+i).asText();
                    System.out.println(jsonNodes.get("res"+i));
                }
            }else if (EnMsgType.EN_MSG_ADD_FRIEND.toString().equals(srctype)){
                // Add buddy
                queue.offer(jsonNodes.get("code").asInt());
            }else if (EnMsgType.EN_MSG_DEL_FRIEND.toString().equals(srctype)){
                // Delete friends
                queue.offer(jsonNodes.get("code").asInt());
            }else if (EnMsgType.EN_MSG_ACTIVE_STATE.toString().equals(srctype)){
                // Friends online status
                queue.offer(jsonNodes.get("code").asInt());
            }
        }else if (EnMsgType.EN_MSG_VERIFY_PASSWORD.toString().equals(msgtype)){
            // Change Password
            int code = 0;
            code = jsonNodes.get("code").asInt();
            queue.offer(code);
        }else if (EnMsgType.EN_MSG_CHAT.toString().equals(msgtype)){
            // The receiver receives the message    Encapsulate a friend's nickname
            String message = " "+ jsonNodes.get("message").asText();
            // Read the message and display the chat box
            ChatFrame.sb.append(message+"n");
            ChatFrame.displayTextPanel.setText(ChatFrame.sb.toString());
        }
    }
}

3.linkmen.java

This is the successful login interface

package chat.Frame.chat;
import chat.Frame.operation.alterColumn.changeNickname;
import chat.Frame.operation.alterColumn.changePassword;
import chat.Frame.operation.alterColumn.changeSignature;
import chat.Frame.operation.friendHandle.addFriend;
import chat.Frame.operation.friendHandle.delFriend;
import chat.Frame.tipFrame;
import chat.Project.services.sendServers;
import io.netty.channel.Channel;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/**
 *  Contact interface
 */
public class linkmen extends JFrame {
    // Containers
    private JFrame frame;
    // label
    private JLabel  label_2, label_3, label_4, label;
    // nickname
    public static JLabel label_1;
    // Status box
    private JComboBox box, box_1, box_2;
    // picture
    private ImageIcon icon_1, icon;
    // Text
    private JTextField  field_1;
    // Individuality signature
    public static JTextField field;
    // panel
    private JPanel panel_1, panel_3, panel;
    // Scroll panel
    public JScrollPane panel_2;
    // list
    public static JList list;
    // Communication channel with the server
    private Channel channel;
    // User id
    private Integer id;
    // The staging oldPasswd
    public static JLabel label_5,label_6;
    // Friends list array
    private String[] fd;
    // list
    public static DefaultListModel<String> model;
    public linkmen(Integer id, Channel channel,String[] fd) {
        this.id = id;
        this.channel = channel;
        this.fd = fd;
    }
    public void init() {
        // Initialization panel 1 And set the message
        panel_1 = new JPanel();
        panel_1.setLayout(null);
        panel_1.setLocation(0, 0);
        panel_1.setBorder(BorderFactory.createTitledBorder(" index card for files "));
        panel_1.setSize(new Dimension(295, 148));
        panel_1.setOpaque(false);
        // Initialization panel 3 And set the message
        panel_3 = new JPanel();
        panel_3.setLayout(null);
        panel_3.setBorder(BorderFactory.createTitledBorder(" System settings "));
        panel_3.setLocation(0, 617);
        panel_3.setSize(new Dimension(295, 55));
        panel_3.setOpaque(false);
        // Set the avatar label
        label_2 = new JLabel(new ImageIcon("E: Chatting software untitledsrcimageSource4.png"));
        label_2.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        label_2.setBounds(15, 15, 100, 100);
        panel_1.add(label_2);
        // Initial staging tag
        label_5 = new JLabel();
        label_6 = new JLabel();
        // Set the nickname tag
        label_1 = new JLabel("");
        label_1.setBounds(130, 10, 100, 30);
        label_1.setFont(new Font(" Song style ", Font.PLAIN, 18));
        panel_1.add(label_1);
        list = new JList<String>(model);
        // Set the height of each list
        list.setFixedCellHeight(20);
        list.setSelectionBackground(new Color(0xD8FF2F));
        list.addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                // Open a chat window
                if (e.getValueIsAdjusting()) {
                    for (int i = 0; i < model.size(); i++) {
                        if (model.get(i).equals(list.getSelectedValue())){
                            // obtain id Erroneous
                            int ids = new sendServers(channel).getId((String) list.getSelectedValue());
                            if (ids!=0) {
                                new sendServers(channel).friendIsActive(ids);
                                new ChatFrame(ids, channel).setVisible(true);
                            }else{
                                System.out.println(" Friends don't exist ");
                            }
                        }
                    }
                }
            }
        });
        // Initialization Panel two
        panel_2 = new JScrollPane(list);
        panel_2.setBorder(BorderFactory.createTitledBorder(" Contacts "));
        panel_2.setLocation(0, 147);
        panel_2.setSize(new Dimension(295, 470));
        panel_2.getViewport().setOpaque(false);
        list.setOpaque(false);
        panel_2.setOpaque(false);
        // Set online status bBox();
        box = new JComboBox();
        box.addItem(" On-line ");
        box.addItem("uD83DuDCBF stealth ");
        box.addItem("uD83DuDCBB Be busy ");
        box.addItem(" offline ");
        box.setBounds(200, 10, 70, 30);
        panel_1.add(box);
        // Set the tag for your personal signature
        label_4 = new JLabel(" Individuality signature :");
        label_4.setFont(new Font(" Song style ", Font.PLAIN, 16));
        label_4.setForeground(Color.BLUE);
        label_4.setBounds(120, 50, 100, 20);
        panel_1.add(label_4);
        // Set text
        field = new JTextField("");
        field.setBounds(120, 80, 160, 30);
        panel_1.add(field);
        label_3 = new JLabel("uD83DuDD0D");
        label_3.setForeground(Color.RED);
        label_3.setBounds(10, 122, 20, 20);
        panel_1.add(label_3);
        // Set up the search bar
        field_1 = new JTextField();
        field_1.setBounds(30, 120, 250, 25);
        panel_1.add(field_1);
        // Initialize panel three
        box_1 = new JComboBox();
        box_1.addItem("uD83DuDD12uD83DuDD28uD83DuDD13");
        box_1.addItem(" Change Password ");
        box_1.addItem(" Modify nickname ");
        box_1.addItem(" Modify signature ");
        box_1.setBounds(8, 20, 100, 25);
        panel_3.add(box_1);
        box_1.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                if (" Modify signature ".equals(box_1.getSelectedItem())) {
                    // Do it once
                    if (e.getStateChange() == ItemEvent.SELECTED) {
                        changeSignature changeSignature = new changeSignature(linkmen.this);
                        changeSignature.setVisible(true);
                        field.setText(changeSignature.jTextField.getText());
                        String signature = field.getText();
                        // How to store signatures
                        new sendServers(channel).modifySignature(signature, id);
                    }
                }
                if (" Change Password ".equals(box_1.getSelectedItem())) {
                    if (e.getStateChange() == ItemEvent.SELECTED) {
                        changePassword changePassword = new changePassword(linkmen.this);
                        changePassword.setVisible(true);
                        label_5.setText(changePassword.oldPassword.getText());
                        String oldPasswd = label_5.getText();
                        label_6.setText(new String(changePassword.newPassword.getPassword()));
                        String newPasswd = label_6.getText();
                        // To verify
                        new sendServers(channel).verifyPasswd(oldPasswd, id,newPasswd);
                    }
                }
                if (" Modify nickname ".equals(box_1.getSelectedItem())) {
                    if (e.getStateChange() == ItemEvent.SELECTED) {
                        changeNickname changeNickname = new changeNickname(linkmen.this);
                        changeNickname.setVisible(true);
                        label_1.setText(changeNickname.jTextField.getText());
                        String nickname = label_1.getText();
                        // Store nicknames
                        new sendServers(channel).modifyNickname(nickname, id);
                    }
                }
            }
        });
        // Add buddy 、 Delete friends
        box_2 = new JComboBox();
        box_2.addItem("uD83DuDC65");
        box_2.addItem(" Add buddy ");
        box_2.addItem(" Delete friends ");
        box_2.setBounds(170, 20, 100, 25);
        box_2.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                if (" Add buddy ".equals(box_2.getSelectedItem())) {
                    if (e.getStateChange() == ItemEvent.SELECTED) {
                        addFriend addFriend = new addFriend(linkmen.this);
                        addFriend.setVisible(true);
                        // Read what you want to search for ID
                        String friendIds = addFriend.jTextField.getText();
                        // Whether the string is
                        if (judgeDigit(friendIds)){
                            int friendId = Integer.parseInt(friendIds);
                            // Search the database
                            new sendServers(channel).addFriendOperate(friendId,id,label_1.getText());
                        }else {
                            new tipFrame().init(" Input parameter error ");
                        }
                    }
                }
                if (" Delete friends ".equals(box_2.getSelectedItem())) {
                    if (e.getStateChange() == ItemEvent.SELECTED) {
                        delFriend delFriend = new delFriend(linkmen.this);
                        delFriend.setVisible(true);
                        // Delete its database
                        String friendIds = delFriend.TextField.getText();
                        // Whether the string is
                        if(judgeDigit(friendIds)){
                            int friendId = Integer.parseInt(friendIds);
                            // Operating the database
                            new sendServers(channel).delFriendOperate(friendId,id,label_1.getText());
                        }else{
                            new tipFrame().init(" Input parameter error ");
                        }
                    }
                }
            }
        });
        panel_3.add(box_2);
        // Set up frame Information
        frame = new JFrame();
        // Set form information
        frame.setTitle(" tencent QQ");
        // Set up a picture for the form
        icon_1 = new ImageIcon("E: Chatting software untitledsrcimageSource3.png");
        frame.setIconImage(icon_1.getImage());
        icon = new ImageIcon("E: Chatting software untitledsrcimageSource5.png");
        label = new JLabel(icon);
        // Get the second layer of the window , take label Put in
        frame.getLayeredPane().add(label, new Integer(Integer.MIN_VALUE));
        // obtain frame The top container of , And set to transparent
        panel = (JPanel) frame.getContentPane();
        panel.setOpaque(false);
        frame.setLayout(null);
        frame.setLocation(750, 150);
        frame.setSize(287, 700);
        frame.setVisible(true);
        frame.setResizable(false);
        label.setBounds(0, 0, 287, 700);
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.add(panel_1);
        frame.add(panel_2);
        frame.add(panel_3);
    }
    public void mian() {
        // Initialization panel 2 And set the message
        model = new DefaultListModel<>();
        for (int i = 0; i < fd.length; i++) {
            model.addElement(fd[i]);
        }
        init();
        // Update nickname and signature
        new sendServers(channel).update(id);
        // Get the user's nickname , And friends list
        // Set initial style and size of signature and nickname Fonts
        label_1.setFont(new Font(" Song style ", Font.PLAIN, 18));
        field.setFont(new Font(" Song style ", Font.PLAIN, 18));
    }
    // Judge whether it's a number
    private static boolean judgeDigit(String string){
        for (int i = 0; i < string.length(); i++) {
            if (!Character.isDigit(string.charAt(i))){
                return false;
            }
        }
        return true;
    }
}

4.tipFrame

Prompt operation status window

package chat.Frame;
import chat.Frame.chat.linkmen;
import chat.Frame.operation.alterColumn.changeNickname;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class tipFrame extends JDialog {
    private Container container;
    // Display error message
    public JLabel label;
    // confirm button
    private JButton button;
    public tipFrame(){
    }
    public void init(String msg){
        container = getContentPane();
        label = new JLabel(msg);
        label.setBounds(70,0,200,70);
        label.setFont(new Font(" Microsoft YaHei ",Font.PLAIN,20));
        container.add(label);
        button = new JButton(" confirm ");
        button.setBounds(35,50,140,40);
        container.add(button);
        setBounds(780,170,220,140);
        setLayout(null);
        setVisible(true);
        container.setBackground(new Color(0xD8FFD5));
        // Prompt window front
        setAlwaysOnTop(true);
        button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                tipFrame.this.dispose();
            }
        });
    }
}

==

5. Operation example diagram

1. Login screen

 picture

Registering an account and forgetting a password without adding an event is now a device

--

2. Contact interface

 picture

All the functions in this can be used

--

3. Chat interface

 picture

The emoticon button in this one doesn't work well

4. Communication process

 picture

5. Modify the operating

 picture

6. Friend's action

 picture

Project recommend :

2000 many G Computer industry electronic resources sharing ( Continuous updating )

2020 Making friends with meow, the full stack project of wechat apps in 【 Courseware and source code attached 】

Spring Boot Develop a small and beautiful personal blog 【 Courseware and source code attached 】

Java Micro service practice 296 Big video - Grain Mall 【 Code and courseware attached 】

Java The development of micro service and the practice of shopping mall 【 whole 357 Jida project 】- Code and courseware attached

The most complete and detailed data structure and algorithm video -【 Courseware and source code attached 】​​​​​​​

 Insert picture description here

版权声明
本文为[Spiderman can't fly]所创,转载请带上原文链接,感谢
https://javamana.com/2021/01/20210123175527984i.html

  1. 【计算机网络 12(1),尚学堂马士兵Java视频教程
  2. 【程序猿历程,史上最全的Java面试题集锦在这里
  3. 【程序猿历程(1),Javaweb视频教程百度云
  4. Notes on MySQL 45 lectures (1-7)
  5. [computer network 12 (1), Shang Xuetang Ma soldier java video tutorial
  6. The most complete collection of Java interview questions in history is here
  7. [process of program ape (1), JavaWeb video tutorial, baidu cloud
  8. Notes on MySQL 45 lectures (1-7)
  9. 精进 Spring Boot 03:Spring Boot 的配置文件和配置管理,以及用三种方式读取配置文件
  10. Refined spring boot 03: spring boot configuration files and configuration management, and reading configuration files in three ways
  11. 精进 Spring Boot 03:Spring Boot 的配置文件和配置管理,以及用三种方式读取配置文件
  12. Refined spring boot 03: spring boot configuration files and configuration management, and reading configuration files in three ways
  13. 【递归,Java传智播客笔记
  14. [recursion, Java intelligence podcast notes
  15. [adhere to painting for 386 days] the beginning of spring of 24 solar terms
  16. K8S系列第八篇(Service、EndPoints以及高可用kubeadm部署)
  17. K8s Series Part 8 (service, endpoints and high availability kubeadm deployment)
  18. 【重识 HTML (3),350道Java面试真题分享
  19. 【重识 HTML (2),Java并发编程必会的多线程你竟然还不会
  20. 【重识 HTML (1),二本Java小菜鸟4面字节跳动被秒成渣渣
  21. [re recognize HTML (3) and share 350 real Java interview questions
  22. [re recognize HTML (2). Multithreading is a must for Java Concurrent Programming. How dare you not
  23. [re recognize HTML (1), two Java rookies' 4-sided bytes beat and become slag in seconds
  24. 造轮子系列之RPC 1:如何从零开始开发RPC框架
  25. RPC 1: how to develop RPC framework from scratch
  26. 造轮子系列之RPC 1:如何从零开始开发RPC框架
  27. RPC 1: how to develop RPC framework from scratch
  28. 一次性捋清楚吧,对乱糟糟的,Spring事务扩展机制
  29. 一文彻底弄懂如何选择抽象类还是接口,连续四年百度Java岗必问面试题
  30. Redis常用命令
  31. 一双拖鞋引发的血案,狂神说Java系列笔记
  32. 一、mysql基础安装
  33. 一位程序员的独白:尽管我一生坎坷,Java框架面试基础
  34. Clear it all at once. For the messy, spring transaction extension mechanism
  35. A thorough understanding of how to choose abstract classes or interfaces, baidu Java post must ask interview questions for four consecutive years
  36. Redis common commands
  37. A pair of slippers triggered the murder, crazy God said java series notes
  38. 1、 MySQL basic installation
  39. Monologue of a programmer: despite my ups and downs in my life, Java framework is the foundation of interview
  40. 【大厂面试】三面三问Spring循环依赖,请一定要把这篇看完(建议收藏)
  41. 一线互联网企业中,springboot入门项目
  42. 一篇文带你入门SSM框架Spring开发,帮你快速拿Offer
  43. 【面试资料】Java全集、微服务、大数据、数据结构与算法、机器学习知识最全总结,283页pdf
  44. 【leetcode刷题】24.数组中重复的数字——Java版
  45. 【leetcode刷题】23.对称二叉树——Java版
  46. 【leetcode刷题】22.二叉树的中序遍历——Java版
  47. 【leetcode刷题】21.三数之和——Java版
  48. 【leetcode刷题】20.最长回文子串——Java版
  49. 【leetcode刷题】19.回文链表——Java版
  50. 【leetcode刷题】18.反转链表——Java版
  51. 【leetcode刷题】17.相交链表——Java&python版
  52. 【leetcode刷题】16.环形链表——Java版
  53. 【leetcode刷题】15.汉明距离——Java版
  54. 【leetcode刷题】14.找到所有数组中消失的数字——Java版
  55. 【leetcode刷题】13.比特位计数——Java版
  56. oracle控制用户权限命令
  57. 三年Java开发,继阿里,鲁班二期Java架构师
  58. Oracle必须要启动的服务
  59. 万字长文!深入剖析HashMap,Java基础笔试题大全带答案
  60. 一问Kafka就心慌?我却凭着这份,图灵学院vip课程百度云