A collaborative pixel-art drawing application built with a client-server architecture. Multiple users can connect to the same "studio", draw on a shared canvas in real time, and chat with each other — all within the same session.
- Real-time collaborative drawing — all strokes are broadcast to every connected client in the same studio
- Multiple studios — users can create a new studio or join an existing one
- Three drawing tools:
- Pen — draw pixel-by-pixel with adjustable pen size (1–3)
- Bucket (fill) — flood-fill a contiguous area with the selected colour
- Eraser — paint pixels black
- Colour picker — pick any colour from a spectrum image (
color-spectrum.jpg) - Chat panel — send and receive text messages within your studio
- Save / Load — save the current canvas to a file and load it back later
- Clear canvas — wipe the entire studio canvas
- Server discovery via UDP broadcast — clients automatically discover the server on the local network; no manual IP entry required
KidPaint Project/
├── KidPaint/ # Client application
│ ├── color-spectrum.jpg # Colour picker image (must be in the working directory)
│ ├── bin/ # Compiled client .class files
│ └── src/
│ ├── KidPaint.java # Entry point — launches the UI
│ ├── UI.java # Main Swing GUI (paint panel, chat, tools, networking); defines the PaintMode enum (Pixel | Area)
│ └── ColorPicker.java# Colour-picker dialog (reads color-spectrum.jpg)
└── Server/ # Server application
├── bin/ # Compiled server .class file
└── src/
└── Server.java # TCP server + UDP discovery responder
- Listens for TCP connections on port
12345to handle client sessions. - Listens for UDP broadcasts on port
55555to help clients discover the server automatically on a local network. - When a client connects it:
- Sends the list of currently active studios to the client.
- Receives the client's chosen (or newly created) studio number.
- Replays the full drawing history of that studio to the new client so they see the current state of the canvas.
- Forwards subsequent messages (draw, bucket-fill, clear, chat) to all other clients in the same studio.
- Studio state (all paint operations) is kept in memory; it is lost when the server restarts.
- On startup the client:
- Asks for a username.
- Sends a UDP broadcast to discover the server; receives the server's IP and port in reply.
- Connects via TCP and receives the studio list.
- Shows the studio lobby — create a new studio or join an existing one.
- After joining a studio the main painting window appears with:
- A canvas (grid of coloured circles, default 50 × 50 blocks at 16 px each).
- A toolbar (colour swatch, Pen / Bucket / Eraser toggle buttons, pen-size cycling, Save, Load, Clear).
- A chat panel on the right (text input + scrollable message history).
- Every mouse drag (pen/eraser) or fill operation is sent to the server as a typed binary message; the server relays it to all peers in the studio.
Type (int) |
Direction | Payload |
|---|---|---|
0 |
both | Chat message — name length, name bytes, message length, message bytes |
1 |
both | Single pixel — colour (int), x (int), y (int) |
2 |
both | Bucket fill — count (int), colour (int), then count × (x, y) pairs |
3 |
server → client | Studio list — count (int), then count studio IDs |
3 |
client → server | Clear canvas (same wire format as bucket fill) |
- Java 8 or later (JDK for compiling, JRE for running)
- Both the server and all clients must be on the same local network (UDP broadcast is used for discovery)
cd "KidPaint Project/Server"
javac -d bin src/Server.javacd "KidPaint Project/KidPaint"
javac -d bin src/ColorPicker.java src/UI.java src/KidPaint.javaNote: The
PaintModeenum is defined insideUI.java, so there is no separatePaintMode.javato compile.
cd "KidPaint Project/Server"
java -cp bin ServerYou should see:
Listening at port : 12345
Open a new terminal for each player (they can all be on different machines on the same network):
cd "KidPaint Project/KidPaint"
java -cp bin KidPaintThe
color-spectrum.jpgfile must be in the current working directory when the client is launched (KidPaint Project/KidPaint/), becauseColorPickerloads it with a relative path.
- Enter your username and click Submit.
- The client discovers the server automatically via UDP broadcast.
- Either Create New Studio (enter canvas width and height, both ≥ 40) or select an existing studio number and click Choose.
- Draw, fill, erase, chat, save, and load to your heart's content!
- The server stores drawing history in memory only; restarting the server clears all studios.
- The UDP discovery broadcasts to
255.255.255.255; make sure your firewall allows UDP on port55555and TCP on port12345. - The client hard-codes UDP bind port
43215; only one client instance can run per machine unless that port is made dynamic. - Pen size cycles through 1 → 2 → 3 → 1 by clicking the Pen button.