Java CS Code

Made by Skyzhou


IntelliJ IDEA Project

Based on JavaFX, MySQL.

An CUHKSZ CSC1004 Assignment (Link)

Github Link : Java Chat Room NOT OPEN YET

Introduction

A simple Java chatroom with GUI based on JavaFX. Two codes included.

Server code running on local port 8023, with JDBC’s MySQL “jdbc:mysql://localhost:3306/JavaChat”. Thread and socket are applied.

Client code can be run for serval times, which are not conflicted with each other. Socket still using local port 8023. After entered the username you will be able to send messages in the chatroom, and ID will be assigned automatically.

You can use “Ctrl + F” to start a search window in the client, where you can search for any messages or users sent before.

The MySQL database is built on local MySQL. So you need to create a database JavaChat before starting the server code, and tables log and users are required. You can initialize the database like this (if you have MySQL):

1
2
3
4
CREATE DATABASE JavaChat;
USE JavaChat;
CREATE TABLE users(id INT, name VARCHAR(100));
CREATE TABLE log(IND INT, text VARCHAR(1000));

After initialize the database, you can launch IDEA and open the project. Set your own JavaFX library. Run the server.java using IDEA’s run “Server”. Then run Main.java using IDEA’s run “Run JavaFX”.

Functions

  • Basic Features
    • Multithreading Implementation
    • Chat Room Functions
    • Message Display
  • Advanced Features
    • Chat Record Storage
    • Search Function

Test images

ClientTest

SearchTest


Thank Jake and SRQ for testing the code!


本站由 Sky Zhou 使用 Stellar 1.29.1 主题创建。
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。
© Copyright skyzhou.top
All Rights Reserved