diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml
index 4abce43..f071bc4 100644
--- a/nbproject/build-impl.xml
+++ b/nbproject/build-impl.xml
@@ -46,8 +46,8 @@ is divided into following sections:
-
-
+
+
@@ -76,7 +76,7 @@ is divided into following sections:
-
+
@@ -156,6 +156,7 @@ is divided into following sections:
+
@@ -840,7 +841,7 @@ is divided into following sections:
-
+
@@ -852,7 +853,7 @@ is divided into following sections:
-
+
@@ -975,15 +976,15 @@ is divided into following sections:
-
+
-
+
-
+
@@ -991,7 +992,7 @@ is divided into following sections:
-
+
@@ -1186,7 +1187,7 @@ is divided into following sections:
Must select one file in the IDE or set run.class
-
+
Must select one file in the IDE or set applet.url
diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties
index cb2d623..a1e02d5 100644
--- a/nbproject/genfiles.properties
+++ b/nbproject/genfiles.properties
@@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=8064a381@1.75.1.48
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=6d39ee20
-nbproject/build-impl.xml.script.CRC32=681df6e3
-nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.1.48
+nbproject/build-impl.xml.script.CRC32=5c486f47
+nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties
index 1b6c36a..d6d76f6 100644
--- a/nbproject/private/private.properties
+++ b/nbproject/private/private.properties
@@ -1,2 +1,2 @@
compile.on.save=true
-user.properties.file=C:\\Users\\ANDITYAARIFIANTO\\AppData\\Roaming\\NetBeans\\8.1\\build.properties
+user.properties.file=C:\\Users\\ASUS\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml
index 52e3867..ea6362c 100644
--- a/nbproject/private/private.xml
+++ b/nbproject/private/private.xml
@@ -3,9 +3,16 @@
- file:/C:/Users/ANDITYAARIFIANTO/Documents/GitHub/Task_4/src/javaChat/ClientConnection.java
- file:/C:/Users/ANDITYAARIFIANTO/Documents/GitHub/Task_4/src/javaChat/ServerConnection.java
- file:/C:/Users/ANDITYAARIFIANTO/Documents/GitHub/Task_4/src/javaChat/Connection.java
+ file:/C:/Users/ASUS/Documents/GitHub/Task_4/src/chatGUI/ChatView.java
+ file:/C:/Users/ASUS/Documents/GitHub/Task_4/src/Driver/DriverServer.java
+ file:/C:/Users/ASUS/Documents/GitHub/Task_4/src/javaChat/ClientConnection.java
+ file:/C:/Users/ASUS/Documents/GitHub/Task_4/src/Driver/DriverClientGui.java
+ file:/C:/Users/ASUS/Documents/GitHub/Task_4/src/chatGUI/JChatController.java
+ file:/C:/Users/ASUS/Documents/GitHub/Task_4/src/javaChat/ConsoleApplication.java
+ file:/C:/Users/ASUS/Documents/GitHub/Task_4/src/javaChat/ConnectionThread.java
+ file:/C:/Users/ASUS/Documents/GitHub/Task_4/src/javaChat/Connection.java
+ file:/C:/Users/ASUS/Documents/GitHub/Task_4/src/javaChat/ServerConnection.java
+ file:/C:/Users/ASUS/Documents/GitHub/Task_4/src/Driver/DriverClientConsole.java
diff --git a/src/Driver/DriverClientConsole.java b/src/Driver/DriverClientConsole.java
new file mode 100644
index 0000000..6f259d7
--- /dev/null
+++ b/src/Driver/DriverClientConsole.java
@@ -0,0 +1,20 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package Driver;
+
+import javaChat.ConsoleApplication;
+
+/**
+ *
+ * @author Fadhlillah
+ */
+public class DriverClientConsole {
+
+ public static void main(String[] args) {
+ ConsoleApplication Ca = new ConsoleApplication();
+ Ca.startChat();
+ }
+}
diff --git a/src/Driver/DriverClientGui.java b/src/Driver/DriverClientGui.java
new file mode 100644
index 0000000..2578b71
--- /dev/null
+++ b/src/Driver/DriverClientGui.java
@@ -0,0 +1,20 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package Driver;
+
+import chatGUI.JChatController;
+
+/**
+ *
+ * @author Fadhlillah
+ */
+public class DriverClientGui {
+
+ public static void main(String[] args) {
+ JChatController Jc = new JChatController();
+
+ }
+}
diff --git a/src/Driver/DriverServer.java b/src/Driver/DriverServer.java
new file mode 100644
index 0000000..e45b845
--- /dev/null
+++ b/src/Driver/DriverServer.java
@@ -0,0 +1,31 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package Driver;
+
+import java.io.IOException;
+import javaChat.ConnectionThread;
+import javaChat.ServerConnection;
+
+/**
+ *
+ * @author Fadhlillah
+ */
+public class DriverServer {
+
+ public static void main(String[] args) throws IOException {
+ try {
+ ServerConnection server = new ServerConnection();
+ System.out.println("Server Information");
+ System.out.println(server.getServerInformation());
+ while (true){
+ ConnectionThread connection = new ConnectionThread(server.getClient());
+ connection.run();
+ }
+ } catch(IOException E){
+ System.out.println("Error");
+ }
+ }
+}
diff --git a/src/chatGUI/ChatView.form b/src/chatGUI/ChatView.form
new file mode 100644
index 0000000..195b57a
--- /dev/null
+++ b/src/chatGUI/ChatView.form
@@ -0,0 +1,69 @@
+
+
+
diff --git a/src/chatGUI/ChatView.java b/src/chatGUI/ChatView.java
new file mode 100644
index 0000000..5c6b18c
--- /dev/null
+++ b/src/chatGUI/ChatView.java
@@ -0,0 +1,96 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package chatGUI;
+
+import javax.swing.JButton;
+import javax.swing.JTextField;
+import java.awt.event.ActionListener;
+
+/**
+ *
+ * @author Fadhlillah
+ */
+public class ChatView extends javax.swing.JFrame {
+
+ /**
+ * Creates new form ChatView
+ */
+ public ChatView() {
+ initComponents();
+ }
+
+ /**
+ * This method is called from within the constructor to initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is always
+ * regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jScrollPane1 = new javax.swing.JScrollPane();
+ txAreaChat = new javax.swing.JTextArea();
+ txFieldChat = new javax.swing.JTextField();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+
+ txAreaChat.setEditable(false);
+ txAreaChat.setColumns(20);
+ txAreaChat.setRows(5);
+ txAreaChat.setText("Input Server IP Address : ");
+ jScrollPane1.setViewportView(txAreaChat);
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(txFieldChat)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 237, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(txFieldChat, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+
+ pack();
+ }// //GEN-END:initComponents
+
+ public void setTxAreaChat(String message){
+ txAreaChat.append(message + "\n");
+ }
+
+ public Object getTxFieldChat(){
+ return txFieldChat;
+ }
+
+ public String getStringChat(){
+ return txFieldChat.getText();
+ }
+
+ public void setTxFieldChat(String message){
+ this.txFieldChat.setText(message);
+ }
+
+
+ public void addListener(ActionListener e){
+ txFieldChat.addActionListener(e);
+ }
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JScrollPane jScrollPane1;
+ private javax.swing.JTextArea txAreaChat;
+ private javax.swing.JTextField txFieldChat;
+ // End of variables declaration//GEN-END:variables
+}
diff --git a/src/chatGUI/JChatController.java b/src/chatGUI/JChatController.java
new file mode 100644
index 0000000..dd02ae4
--- /dev/null
+++ b/src/chatGUI/JChatController.java
@@ -0,0 +1,65 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package chatGUI;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.IOException;
+import javaChat.ClientConnection;
+import javax.swing.text.View;
+
+/**
+ *
+ * @author Fadhlillah
+ */
+public class JChatController implements ActionListener {
+
+ private ChatView view;
+ private ClientConnection client;
+
+ public JChatController() {
+ view = new ChatView();
+ view.setVisible(true);
+ view.addListener(this);
+ client = null;
+ }
+
+ public class WriteOutput extends Thread {
+
+ public void run() {
+ String inputan;
+ try {
+ while ((inputan = client.readStream()) != null) {
+ view.setTxAreaChat(inputan);
+ }
+ } catch (IOException E) {
+ System.out.println("Error");
+ }
+ }
+ }
+
+ public void actionPerformed(ActionEvent ae) {
+ Object source = ae.getSource();
+
+ if (source.equals(view.getTxFieldChat())) {
+ if (client == null) {
+ try {
+ client = new ClientConnection();
+ String ip = view.getStringChat();
+ client.connect(ip);
+ WriteOutput w = new WriteOutput();
+ w.start();
+ } catch (IOException E){
+ System.out.println("Error");
+ }
+ } else {
+ String input = view.getStringChat();
+ client.writeStream(input);
+ view.setTxFieldChat("");
+ }
+ }
+ }
+}
diff --git a/src/javaChat/ConnectionThread.java b/src/javaChat/ConnectionThread.java
new file mode 100644
index 0000000..f7376bf
--- /dev/null
+++ b/src/javaChat/ConnectionThread.java
@@ -0,0 +1,52 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package javaChat;
+
+import java.io.IOException;
+import java.net.Socket;
+import javaChat.Connection;
+
+/**
+ *
+ * @author Fadhlillah
+ */
+public class ConnectionThread {
+
+ private Socket client;
+ private Connection connection;
+
+ public ConnectionThread(Socket newClient) throws IOException {
+ this.client = newClient;
+ connection = new Connection(client);
+ }
+
+ public void run() throws IOException {
+ try {
+ connection.startChat("Start the Chat");
+
+ System.out.println("--------------");
+ System.out.println("New Client Connected");
+ System.out.println("Client Information");
+ System.out.println(connection.getClientInformation());
+
+ String inputan;
+ String message;
+ while ((inputan = connection.readStream()) != null
+ && !inputan.equals("Quit")) {
+ message = "Client " + connection.getIpClient() + "said : " + inputan;
+ System.out.println(message);
+ connection.sendToAll(message);
+ }
+ message = "Client from IP : " + connection.getIpClient()
+ + "Quit the chat Room";
+ System.out.println(message);
+ connection.sendToAll(message);
+ connection.disconnect();
+ } catch (IOException E) {
+ System.out.println("Error");
+ }
+ }
+}
diff --git a/src/javaChat/ConsoleApplication.java b/src/javaChat/ConsoleApplication.java
new file mode 100644
index 0000000..a7a80c3
--- /dev/null
+++ b/src/javaChat/ConsoleApplication.java
@@ -0,0 +1,67 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package javaChat;
+
+import java.io.IOException;
+import javaChat.ClientConnection;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author Fadhlillah
+ */
+public class ConsoleApplication {
+
+ private ClientConnection client;
+ public class ReadInput extends Thread {
+
+ public void run() {
+ try {
+ String inputKeyboard;
+ do {
+ System.out.println(">>");
+ inputKeyboard = client.inputString();
+ client.writeStream(inputKeyboard);
+ } while(! inputKeyboard.equals("Quit"));
+ client.disconnect();
+ } catch(IOException E) {
+ System.out.println("Error");
+ }
+ }
+ }
+
+ public class WriteOutput extends Thread {
+
+ public void run() {
+ try {
+ String inputan;
+ while ((inputan = client.readStream()) != null) {
+ System.out.println(inputan);
+ System.out.println(">>");
+ }
+ } catch (IOException E) {
+ System.out.println("Error");
+ }
+ }
+ }
+
+ public void startChat() {
+
+ try {
+ client = new ClientConnection();
+ System.out.println("Input server IP :");
+ String ip = client.inputString();
+ client.connect(ip);
+ ReadInput in = new ReadInput();
+ WriteOutput out = new WriteOutput();
+ in.start();
+ out.start();
+ } catch (IOException E) {
+ System.out.println("error");
+ }
+ }
+}