Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,839 changes: 1,420 additions & 1,419 deletions nbproject/build-impl.xml

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions nbproject/genfiles.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
build.xml.data.CRC32=6d39ee20
build.xml.script.CRC32=528642be
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
build.xml.data.CRC32=6d39ee20
build.xml.script.CRC32=528642be
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=5c486f47
nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
4 changes: 2 additions & 2 deletions nbproject/private/private.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
compile.on.save=true
user.properties.file=C:\\Users\\ANDITYAARIFIANTO\\AppData\\Roaming\\NetBeans\\8.1\\build.properties
compile.on.save=true
user.properties.file=C:\\Users\\USER\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
20 changes: 20 additions & 0 deletions src/Driver/DriverClientConsole.java
Original file line number Diff line number Diff line change
@@ -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 consoleApp.ConsoleApplication;

/**
*
* @author Herica Bunga M (1301154572)
*/
public class DriverClientConsole {
public static void main(String[] args) {
ConsoleApplication app = new ConsoleApplication();
app.startChat();
}
}

18 changes: 18 additions & 0 deletions src/Driver/DriverClientGui.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* 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.ChatController;

/**
*
* @author USER
*/
public class DriverClientGui {
public static void main(String[] args) {
new ChatController();
}
}
31 changes: 31 additions & 0 deletions src/Driver/DriverServer.java
Original file line number Diff line number Diff line change
@@ -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 consoleApp.ConnectionThread;
import java.io.IOException;
import javaChat.ServerConnection;

/**
*
* @author Herica Bunga M (1301154572)
*/
public class DriverServer {
public static void main(String[] args) {
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 ex) {
System.out.println("Error");
}
}
}

67 changes: 67 additions & 0 deletions src/chatGUI/ChatController.java
Original file line number Diff line number Diff line change
@@ -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 chatGUI;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import javaChat.ClientConnection;
import javax.swing.JOptionPane;

/**
*
* @author Herica Bunga M (1301154572)
*/
public class ChatController implements ActionListener {
private ChatView view;
private ClientConnection client;

public ChatController() {
view = new ChatView();
view.setVisible(true);
view.addListener(this);
client = null;
}

@Override
public void actionPerformed(ActionEvent ae) {
Object source = ae.getSource();
if (source.equals(view.getTxFieldChat())) {
if (client == null){
try {
client = new ClientConnection();
view.setTxAreaChat(view.getStringChat());
String ip = view.getStringChat();
client.connect(ip);
WriteOutput w = new WriteOutput();
w.start();
} catch (IOException ex) {
JOptionPane.showMessageDialog(null, "Error");
}
}
else {
String input = view.getStringChat();
client.writeStream(input);
view.setTxFieldChat("");
}
}
}

public class WriteOutput extends Thread {

public void run() {
try {
String inp;
while ((inp = client.readStream()) != null) {
view.setTxAreaChat(inp);
}
} catch (IOException ex) {
System.out.println("Error");
}
}
}
}

72 changes: 72 additions & 0 deletions src/chatGUI/ChatView.form
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8" ?>

<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="3"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>

<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" pref="380" max="32767" attributes="0"/>
<Component id="txFieldChat" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane1" min="-2" pref="252" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="txFieldChat" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>

<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTextArea" name="txAreaChat">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="columns" type="int" value="20"/>
<Property name="rows" type="int" value="5"/>
<Property name="text" type="java.lang.String" value="Input Server IP Address : "/>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JTextField" name="txFieldChat">
<Properties>
<Property name="editable" type="boolean" value="false"/>
</Properties>
</Component>
</SubComponents>
</Form>
99 changes: 99 additions & 0 deletions src/chatGUI/ChatView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* 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.ActionListener;

/**
*
* @author Herica Bunga M (1301154572)
*/
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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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);

txFieldChat.setEditable(false);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
.addComponent(txFieldChat))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 252, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txFieldChat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);

pack();
}// </editor-fold>//GEN-END:initComponents

/**
* @param args the command line arguments
*/

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 ae){
txFieldChat.addActionListener(ae);
}

// 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
}
49 changes: 49 additions & 0 deletions src/consoleApp/ConnectionThread.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* 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 consoleApp;

import java.io.IOException;
import java.net.Socket;
import javaChat.Connection;

/**
*
* @author Herica Bunga M (1301154572)
*/
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 () {
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 from chat room ";
System.out.println(message);
connection.sendToAll(message);
connection.disconnect();
} catch (IOException e) {
System.out.println("Error");
}
}
}

Loading