diff --git a/src/GUI/ChatScreen.java b/src/GUI/ChatScreen.java
index b9b69e072c00eaa6e19ba0fcffca2c7b4ba5ee33..0c43cd56aa801ee4e5c3f6b6c891e93f1c4a53cd 100644
--- a/src/GUI/ChatScreen.java
+++ b/src/GUI/ChatScreen.java
@@ -33,28 +33,23 @@ public class ChatScreen {
private JButton quitButton;
private JFrame frame;
- private Client client;
+ public Client getClient() {
+ return client;
+ }
+
+ public Client client;
public ChatScreen(Client client)
{
this.client = client;
- yourNameDisplay.setText(client.getUserName());
-// sentMessageToComboBox.addItem(client.getUserName());
exitThisRoomButton.addActionListener(actionListener);
sendButton.addActionListener(actionListener);
- frame = new JFrame("Application");
- frame.setContentPane(panel2);
- createUIComponents();
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.pack();
- frame.setResizable(false);
- frame.setVisible(true);
+ yourNameDisplay.setText(client.getUserName());
+ drawingPanel = new PaintGUI(client);
}
- private void createUIComponents() {
- drawingPanel = new PaintGUI(client).getGlobal();
- }
+
public JTextArea getChatDisplayBox() {
return chatDisplayBox;
@@ -104,4 +99,20 @@ public class ChatScreen {
}
};
+
+ public void showGUI() {
+ frame = new JFrame("Application");
+ JFrame.setDefaultLookAndFeelDecorated(true);
+ frame.setContentPane(panel2);
+ createUIComponents();
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.pack();
+ frame.setResizable(false);
+ frame.setVisible(true);
+ }
+
+ private void createUIComponents() {
+// PaintGUI paintGUI = new PaintGUI(client);
+ drawingPanel = new PaintGUI(client).getGlobal();
+ }
}
diff --git a/src/GUI/PaintGUI.java b/src/GUI/PaintGUI.java
index 78fa2e8dc6516636633e884d905750fe930dc41b..2995d3be8c34304669416ed3df79c001f413c4e8 100644
--- a/src/GUI/PaintGUI.java
+++ b/src/GUI/PaintGUI.java
@@ -10,7 +10,8 @@ import java.io.File;
public class PaintGUI extends JPanel {
-
+ Client client;
+ ChatScreen chatScreen;
String[] shapes = {"Freehand", "Line", "Circle", "Rectangle", "Oval", "Eraser"};
String[] colors = {"Aqua", "Black", "Blue", "Fuchsia", "Gray", "Green", "Lime", "Maroon", "Navy", "Olive", "Purple", "Red", "Silver", "Teal", "White", "Yellow"};
@@ -19,7 +20,8 @@ public class PaintGUI extends JPanel {
JComboBox colorOptions;
JComboBox shapeOptions;
DrawingArea drawingArea;
- Client client;
+
+
JPanel global = new JPanel();
JFileChooser fileChooser= new JFileChooser();
JPanel toolbox = new JPanel();
@@ -27,10 +29,11 @@ public class PaintGUI extends JPanel {
/// GUI setup ///
public PaintGUI(Client client) {
+
this.client = client;
/// Main drawing area ///
- drawingArea = new DrawingArea(client);
+ drawingArea = new DrawingArea(this.client);
/// Set up main frame and container ///
global.setLayout(new BorderLayout());
@@ -215,16 +218,16 @@ public class PaintGUI extends JPanel {
-// public void showGUI() {
-// frame = new JFrame("Shared Whiteboard System");
-// JFrame.setDefaultLookAndFeelDecorated(true);
-// frame.setContentPane(global);
-//
-// frame.setSize(800, 600);
-// frame.setLocationRelativeTo( null );
-// frame.setResizable(false);
-// frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-// frame.setVisible(true);
-// }
+ public void showGUI() {
+ frame = new JFrame("Shared Whiteboard System");
+ JFrame.setDefaultLookAndFeelDecorated(true);
+ frame.setContentPane(global);
+
+ frame.setSize(800, 600);
+ frame.setLocationRelativeTo( null );
+ frame.setResizable(false);
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setVisible(true);
+ }
}
\ No newline at end of file
diff --git a/src/client/Client.java b/src/client/Client.java
index 592b566b80efe3215d31915b4e0ece0bac29fc65..ef1939cbdd44061af06cfc932cf65f3a89b26ce2 100644
--- a/src/client/Client.java
+++ b/src/client/Client.java
@@ -13,7 +13,6 @@ import java.rmi.registry.Registry;
public class Client
{
- //test
private String userName;
private String serverAddress;
@@ -28,11 +27,11 @@ public class Client
private StartScreen startScreen;
private ChatScreen chatScreen;
-// private PaintGUI paintGUI;
+ private PaintGUI paintGUI;
-// public PaintGUI getPaintGUI() {
-// return paintGUI;
-// }
+ public PaintGUI getPaintGUI() {
+ return paintGUI;
+ }
public ChatScreen getChatScreen()
@@ -40,10 +39,6 @@ public class Client
return chatScreen;
}
-
-
- private String receivedMessage;
-
public IChatController getChatController()
{
return chatController;
@@ -77,7 +72,7 @@ public class Client
this.clientUpdate = new ClientUpdate(this);
this.chatUpdate = new ChatUpdate(this);
this.drawingUpdate = new DrawingUpdate(this);
- this.startScreen = new StartScreen(this);
+// this.startScreen = new StartScreen(this);
this.chatScreen = new ChatScreen(this);
// this.paintGUI = new PaintGUI(this);
}
@@ -88,7 +83,7 @@ public class Client
{
Client client = new Client(args[0]);
client.connect();
-// client.startScreen.go();
+ client.chatScreen.showGUI();
// client.getPaintGUI().showGUI();
}
catch (Exception e)
@@ -107,7 +102,7 @@ public class Client
clientController = (IClientController) registryServer.lookup("ClientController");
drawingController = (IDrawingController) registryServer.lookup("DrawingController");
- if (clientController.join(userName, this.chatUpdate, this.drawingUpdate))
+ if (clientController.join(userName, this.chatUpdate, this.drawingUpdate, this.clientUpdate))
{
System.out.println("Connected to server");
diff --git a/src/client/DrawingUpdate.java b/src/client/DrawingUpdate.java
index 1a6cf0cdb3972d33ed25720fd5a6073390647fa1..d681f1aa85f9a116686ea320a10371c6f7d884b9 100644
--- a/src/client/DrawingUpdate.java
+++ b/src/client/DrawingUpdate.java
@@ -1,5 +1,6 @@
package client;
+import GUI.DrawingArea;
import remote.IDrawingUpdate;
import java.awt.*;
@@ -18,9 +19,11 @@ public class DrawingUpdate extends UnicastRemoteObject implements IDrawingUpdate
@Override
public boolean notifyDrawing(String fromClient, Shape drawing) throws RemoteException {
-// client.getPaintGUI().getDrawingArea().setDrawing(drawing);
-// client.getPaintGUI().getDrawingArea().repaint();
- client.getChatScreen().getDrawingPanel().getRootPane();
+ client.getPaintGUI().getDrawingArea().setDrawing(drawing);
+ client.getPaintGUI().getDrawingArea().repaint();
+ DrawingArea drawingArea = (DrawingArea) client.getChatScreen().getDrawingPanel().getComponent(1);
+ drawingArea.setDrawing(drawing);
+ drawingArea.repaint();
return false;
}
}
diff --git a/src/remote/IClientController.java b/src/remote/IClientController.java
index 70447fe97b800d4f5c90805d74153ea70498e316..35539cdc112a8cd5f2e78eeeddf911a74e9abb88 100644
--- a/src/remote/IClientController.java
+++ b/src/remote/IClientController.java
@@ -5,7 +5,7 @@ import java.rmi.RemoteException;
public interface IClientController extends Remote
{
- boolean join(String username, IChatUpdate clientChat, IDrawingUpdate clientDrawing) throws RemoteException;
+ boolean join(String username, IChatUpdate clientChat, IDrawingUpdate clientDrawing, IClientUpdate clientUpdate) throws RemoteException;
void quit(String username) throws RemoteException;
diff --git a/src/remote/IUpdateController.java b/src/remote/IUpdateController.java
deleted file mode 100644
index caad27c6264f84f0e9890a2e954f58d6510b7e7d..0000000000000000000000000000000000000000
--- a/src/remote/IUpdateController.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package remote;
-
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-import java.util.ArrayList;
-
-/**
- * RMI Remote interface - IRemoteUpdate.
- * Allows Server to command Client to update: canvas, chat, other.
- */
-
-public interface IUpdateController extends Remote {
-
- public void updateClient(String text) throws RemoteException;
- public ArrayList<String> getUserList() throws RemoteException;
- public void updateUserList(ArrayList userList) throws RemoteException;
-}
diff --git a/src/server/ClientController.java b/src/server/ClientController.java
index f3753fa6f0ad8660d87cb0cb91163a699329d17b..267c0cb3961c90419ef9970d7b2a192e812d8627 100644
--- a/src/server/ClientController.java
+++ b/src/server/ClientController.java
@@ -1,8 +1,9 @@
package server;
import remote.IChatUpdate;
-import remote.IClientController;
+import remote.IClientUpdate;
import remote.IDrawingUpdate;
+import remote.IClientController;
import java.io.Serializable;
import java.rmi.RemoteException;
@@ -18,11 +19,11 @@ public class ClientController extends UnicastRemoteObject implements IClientCont
}
@Override
- public boolean join(String username, IChatUpdate clientChat, IDrawingUpdate clientDrawing) throws RemoteException
+ public boolean join(String username, IChatUpdate clientChat, IDrawingUpdate clientDrawing, IClientUpdate clientUpdate) throws RemoteException
{
server.chatController.broadcastMessageUserLogin(username);
- User newUser = new User(username, clientChat, clientDrawing);
+ User newUser = new User(username, clientChat, clientDrawing, clientUpdate);
server.users.add(newUser);
diff --git a/src/server/Server.java b/src/server/Server.java
index 0971b974feaf49386eb2ea18664c0dbc6bf91c7b..65842248bec9de49f36f79a9e29c9e2eface21a3 100644
--- a/src/server/Server.java
+++ b/src/server/Server.java
@@ -15,12 +15,14 @@ public class Server
protected ClientController clientController;
protected ChatController chatController;
+ protected DrawingController drawingController;
public Server() throws RemoteException
{
users = new ArrayList<User>();
clientController = new ClientController(this);
chatController = new ChatController(this);
+ drawingController = new DrawingController(this);
}
public static void main(String[] args)
diff --git a/src/server/User.java b/src/server/User.java
index 51047ae656f86c128b532782af263dbd91dceb7a..7211122586603d7709f0861a89f8c6c0e5becd92 100644
--- a/src/server/User.java
+++ b/src/server/User.java
@@ -1,17 +1,23 @@
package server;
+import remote.IChatUpdate;
+import remote.IClientUpdate;
+import remote.IDrawingUpdate;
+
public class User
{
private String username;
- private remote.IChatUpdate IChatUpdate;
- private remote.IDrawingUpdate IDrawingUpdate;
+ private IChatUpdate IChatUpdate;
+ private IDrawingUpdate IDrawingUpdate;
+ private IClientUpdate IClientUpdate;
private boolean isAdmin;
- public User(String username, remote.IChatUpdate IChatUpdate, remote.IDrawingUpdate IDrawingUpdate)
+ public User(String username, IChatUpdate IChatUpdate, IDrawingUpdate IDrawingUpdate, IClientUpdate IClientUpdate)
{
this.username = username;
this.IChatUpdate = IChatUpdate;
this.IDrawingUpdate = IDrawingUpdate;
+ this.IClientUpdate = IClientUpdate;
this.isAdmin = false;
}
@@ -30,10 +36,12 @@ public class User
return isAdmin;
}
- public remote.IChatUpdate getIChatUpdate()
+ public IChatUpdate getIChatUpdate()
{
return this.IChatUpdate;
}
- public remote.IDrawingUpdate getIDrawingUpdate() { return this.IDrawingUpdate; }
+ public IDrawingUpdate getIDrawingUpdate() { return this.IDrawingUpdate; }
+
+ public IClientUpdate getIClientUpdate() { return this.IClientUpdate; }
}