Skip to content
Snippets Groups Projects
Commit 9e5c888c authored by Ho Dac Hai's avatar Ho Dac Hai
Browse files

Merge branch 'hai' into 'master'

parents d143d6ad f4f4b9dc
Branches
Tags
No related merge requests found
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
......@@ -58,24 +58,15 @@ public class PaintGUI extends JPanel {
/// Set up button icons ///
try {
String path = System.getProperty("user.dir");
System.out.println(path);
File palettePic = new File(path + "/src/GUI/icon/palette.png");
File freehandPic = new File(path + "/src/GUI/icon/freehand.png");
File linePic = new File(path + "/src/GUI/icon/line.png");
File circlePic = new File(path + "/src/GUI/icon/circle.png");
File rectPic = new File(path + "/src/GUI/icon/rectangle.png");
File ovalPic = new File(path + "/src/GUI/icon/oval.png");
File eraserPic = new File(path + "/src/GUI/icon/eraser.png");
File textPic = new File(path + "/src/GUI/icon/text.png");
BufferedImage paletteIcon = ImageIO.read(palettePic);
BufferedImage freehandIcon = ImageIO.read(freehandPic);
BufferedImage lineIcon = ImageIO.read(linePic);
BufferedImage circleIcon = ImageIO.read(circlePic);
BufferedImage rectIcon = ImageIO.read(rectPic);
BufferedImage ovalIcon = ImageIO.read(ovalPic);
BufferedImage eraserIcon = ImageIO.read(eraserPic);
BufferedImage textIcon = ImageIO.read(textPic);
BufferedImage paletteIcon = ImageIO.read(getClass().getResource("/palette.png"));
BufferedImage freehandIcon = ImageIO.read(getClass().getResource("/freehand.png"));
BufferedImage lineIcon = ImageIO.read(getClass().getResource("/line.png"));
BufferedImage circleIcon = ImageIO.read(getClass().getResource("/circle.png"));
BufferedImage rectIcon = ImageIO.read(getClass().getResource("/rectangle.png"));
BufferedImage ovalIcon = ImageIO.read(getClass().getResource("/oval.png"));
BufferedImage eraserIcon = ImageIO.read(getClass().getResource("/eraser.png"));
BufferedImage textIcon = ImageIO.read(getClass().getResource("/text.png"));
colorPaletteBtn = new JButton(new ImageIcon(paletteIcon));
colorPaletteBtn.addActionListener(actionListener);
freehandBtn = new JButton(new ImageIcon(freehandIcon));
......
......@@ -46,8 +46,8 @@ public class StartScreen {
String userName = usernameField.getText();
String password = new String(passwordField.getPassword());
if (userName.length() <= 15) {
int connectionStatus = client.connect(userName, serverAddress, password);
if( connectionStatus == 1 )
{
frame.setVisible(false);
......@@ -85,6 +85,10 @@ public class StartScreen {
showErrorMessage("Unknown Connection Status");
}
}
else {
showErrorMessage("Username must be less or equal to 15 characters");
}
}
}
};
......
......@@ -93,9 +93,9 @@ public class Client
}
public Client(String username) throws RemoteException, NoSuchProviderException, NoSuchAlgorithmException
public Client() throws RemoteException, NoSuchProviderException, NoSuchAlgorithmException
{
this.defaultUserName = username;
this.defaultUserName = DEFAULT_USERNAME;
this.clientUpdate = new ClientUpdate(this);
this.chatUpdate = new ChatUpdate(this);
this.drawingUpdate = new DrawingUpdate(this);
......@@ -108,7 +108,7 @@ public class Client
{
try
{
Client client = new Client(args[0]);
Client client = new Client();
client.showStartScreen();
}
catch (Exception e)
......
......@@ -50,7 +50,7 @@ public class Server
{
Server server = new Server();
server.run();
server.run(args[0]);
}
catch( Exception e )
{
......@@ -58,15 +58,15 @@ public class Server
}
}
public void run() throws RemoteException
public void run(String serverIP) throws RemoteException
{
String serverIP = "";
try {
InetAddress inetAddress = InetAddress.getLocalHost();
serverIP = inetAddress.getHostAddress();
} catch (Exception e) {
e.printStackTrace();
}
// String serverIP = "";
// try {
// InetAddress inetAddress = InetAddress.getLocalHost();
// serverIP = inetAddress.getHostAddress();
// } catch (Exception e) {
// e.printStackTrace();
// }
System.setProperty("java.rmi.server.hostname", serverIP);
......@@ -91,16 +91,18 @@ public class Server
System.out.println("Server is ready");
printIP();
printIP(serverIP);
}
private void printIP()
private void printIP(String serverIP)
{
InetAddress inetAddress = null;
try
{
if (serverIP.isEmpty()) {
inetAddress = InetAddress.getLocalHost();
} else inetAddress = InetAddress.getByName(serverIP);
}
catch (UnknownHostException e)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment