Skip to content

Windesheim-HBO-ICT/Chatbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Chatbox

Java Chatbox assignment

Instructions

Create a chat client using the Windesheim.Chat library. This library is available for download as a .jar file. This file contains a ChatConnector handling the connection to the server and has an interface called ChatClient which provides a callback function MessageReceived.

You will have to write the code that creates a GUI application and lets the user interact with the client.

Import JAR file

  • Download the Windesheim.jar file and save it somewhere on your local harddisk.
  • Create a new project and import the jar file. For NetBeans, follow these steps:
    • Go to File -> Project Properties
    • Go to Libraries, click the Add button (+) for Classpath and select Add JAR/Folder
    • Select the Windesheim.jar file and click Open
    • Click OK to close the dialog

Create a client GUI application

After the Windesheim.jar file has been added, create an application using the following code sample:

import Windesheim.Chat.*;
...

public class MyApplication ... implements ChatClient {
    private ChatConnector connector;
    
    public MyApplication() {
        ...
        this.connector = new ChatConnector(this, "<ip address>", <port>, "<username>");
        this.connector.start();    
    }
    
    // Some method that is called when the user clicks a Send button or presses Enter
    public void ...(...) {
        ...
        
        // Send the message to the server
        connector.SendMessage(message);
    }
    
    // Method that handles incoming messages from the server.
    public void MessageReceived(String message) {
        ...
    }
}

Releases

No releases published

Packages

No packages published

Languages