Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made Rama_1301154203_if3907 #116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build/
21 changes: 11 additions & 10 deletions nbproject/build-impl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ is divided into following sections:
<property file="${user.properties.file}"/>
<!-- The two properties below are usually overridden -->
<!-- by the active platform. Just a fallback. -->
<property name="default.javac.source" value="1.4"/>
<property name="default.javac.target" value="1.4"/>
<property name="default.javac.source" value="1.6"/>
<property name="default.javac.target" value="1.6"/>
</target>
<target depends="-pre-init,-init-private,-init-user" name="-init-project">
<property file="nbproject/configs/${config}.properties"/>
Expand Down Expand Up @@ -76,7 +76,7 @@ is divided into following sections:
<and>
<isset property="javac.profile"/>
<length length="0" string="${javac.profile}" when="greater"/>
<matches pattern="1\.[89](\..*)?" string="${javac.source}"/>
<matches pattern="((1\.[89])|9)(\..*)?" string="${javac.source}"/>
</and>
</condition>
<condition property="do.archive">
Expand Down Expand Up @@ -156,6 +156,7 @@ is divided into following sections:
<property name="application.args" value=""/>
<property name="source.encoding" value="${file.encoding}"/>
<property name="runtime.encoding" value="${source.encoding}"/>
<property name="manifest.encoding" value="${source.encoding}"/>
<condition property="javadoc.encoding.used" value="${javadoc.encoding}">
<and>
<isset property="javadoc.encoding"/>
Expand Down Expand Up @@ -840,7 +841,7 @@ is divided into following sections:
</chainedmapper>
</pathconvert>
<taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
<copylibs compress="${jar.compress}" excludeFromCopy="${copylibs.excludes}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" rebase="${copylibs.rebase}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
<copylibs compress="${jar.compress}" excludeFromCopy="${copylibs.excludes}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" manifestencoding="UTF-8" rebase="${copylibs.rebase}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
<fileset dir="${build.classes.dir}" excludes="${dist.archive.excludes}"/>
<manifest>
<attribute name="Class-Path" value="${jar.classpath}"/>
Expand All @@ -852,7 +853,7 @@ is divided into following sections:
</target>
<target name="-init-presetdef-jar">
<presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
<jar compress="${jar.compress}" index="${jar.index}" jarfile="${dist.jar}">
<jar compress="${jar.compress}" index="${jar.index}" jarfile="${dist.jar}" manifestencoding="UTF-8">
<j2seproject1:fileset dir="${build.classes.dir}" excludes="${dist.archive.excludes}"/>
</jar>
</presetdef>
Expand Down Expand Up @@ -975,23 +976,23 @@ is divided into following sections:
</target>
<target depends="init" if="do.archive+manifest.available" name="-do-jar-copy-manifest">
<tempfile deleteonexit="true" destdir="${build.dir}" property="tmp.manifest.file"/>
<copy file="${manifest.file}" tofile="${tmp.manifest.file}"/>
<copy encoding="${manifest.encoding}" file="${manifest.file}" outputencoding="UTF-8" tofile="${tmp.manifest.file}"/>
</target>
<target depends="init,-do-jar-create-manifest,-do-jar-copy-manifest" if="do.archive+main.class.available" name="-do-jar-set-mainclass">
<manifest file="${tmp.manifest.file}" mode="update">
<manifest encoding="UTF-8" file="${tmp.manifest.file}" mode="update">
<attribute name="Main-Class" value="${main.class}"/>
</manifest>
</target>
<target depends="init,-do-jar-create-manifest,-do-jar-copy-manifest" if="do.archive+profile.available" name="-do-jar-set-profile">
<manifest file="${tmp.manifest.file}" mode="update">
<manifest encoding="UTF-8" file="${tmp.manifest.file}" mode="update">
<attribute name="Profile" value="${javac.profile}"/>
</manifest>
</target>
<target depends="init,-do-jar-create-manifest,-do-jar-copy-manifest" if="do.archive+splashscreen.available" name="-do-jar-set-splashscreen">
<basename file="${application.splash}" property="splashscreen.basename"/>
<mkdir dir="${build.classes.dir}/META-INF"/>
<copy failonerror="false" file="${application.splash}" todir="${build.classes.dir}/META-INF"/>
<manifest file="${tmp.manifest.file}" mode="update">
<manifest encoding="UTF-8" file="${tmp.manifest.file}" mode="update">
<attribute name="SplashScreen-Image" value="META-INF/${splashscreen.basename}"/>
</manifest>
</target>
Expand Down Expand Up @@ -1186,7 +1187,7 @@ is divided into following sections:
<target depends="-profile-check" description="Profile a selected class in the IDE." if="profiler.configured" name="profile-test-with-main">
<fail unless="run.class">Must select one file in the IDE or set run.class</fail>
<startprofiler/>
<antcal target="run-test-with-main"/>
<antcall target="run-test-with-main"/>
</target>
<target depends="-profile-check,-profile-applet-pre72" if="profiler.configured" name="profile-applet" unless="profiler.info.jvmargs.agent">
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
Expand Down
4 changes: 2 additions & 2 deletions nbproject/genfiles.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ [email protected]
# 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
2 changes: 1 addition & 1 deletion 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
user.properties.file=C:\\Users\\GL552JX\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
13 changes: 10 additions & 3 deletions nbproject/private/private.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/C:/Users/ANDITYAARIFIANTO/Documents/GitHub/Task_4/src/javaChat/ClientConnection.java</file>
<file>file:/C:/Users/ANDITYAARIFIANTO/Documents/GitHub/Task_4/src/javaChat/ServerConnection.java</file>
<file>file:/C:/Users/ANDITYAARIFIANTO/Documents/GitHub/Task_4/src/javaChat/Connection.java</file>
<file>file:/C:/Users/GL552JX/Desktop/New%20folder%20(2)/Task_4/src/Driver/DriveClientConsole.java</file>
<file>file:/C:/Users/GL552JX/Desktop/New%20folder%20(2)/Task_4/src/chatGUI/JChatController.java</file>
<file>file:/C:/Users/GL552JX/Desktop/New%20folder%20(2)/Task_4/src/chatGUI/ChatView.java</file>
<file>file:/C:/Users/GL552JX/Desktop/New%20folder%20(2)/Task_4/src/ConsoleApp/ConnectionThread.java</file>
<file>file:/C:/Users/GL552JX/Desktop/New%20folder%20(2)/Task_4/src/javaChat/Connection.java</file>
<file>file:/C:/Users/GL552JX/Desktop/New%20folder%20(2)/Task_4/src/javaChat/ClientConnection.java</file>
<file>file:/C:/Users/GL552JX/Desktop/New%20folder%20(2)/Task_4/src/ConsoleApp/ConsoleApplication.java</file>
<file>file:/C:/Users/GL552JX/Desktop/New%20folder%20(2)/Task_4/src/Driver/DriverClientGui.java</file>
<file>file:/C:/Users/GL552JX/Desktop/New%20folder%20(2)/Task_4/src/Driver/DriverServer.java</file>
<file>file:/C:/Users/GL552JX/Desktop/New%20folder%20(2)/Task_4/src/javaChat/ServerConnection.java</file>
</group>
</open-files>
</project-private>
2 changes: 1 addition & 1 deletion nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
main.class=task.Task
main.class=Driver.DriveClientConsole
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
Expand Down
50 changes: 50 additions & 0 deletions src/ConsoleApp/ConnectionThread.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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 GL552JX
*/
public class ConnectionThread extends Thread {

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 cilent 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 (Exception e) {
System.out.println("Error");
}
}
}
67 changes: 67 additions & 0 deletions src/ConsoleApp/ConsoleApplication.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 ConsoleApp;

import javaChat.ClientConnection;

/**
*
* @author GL552JX
*/
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 (Exception e) {
System.out.println("Error");
}
}
}

public class WriteInput extends Thread{

public void run(){

try {
String inputan;
while ((inputan = client.readStream()) != null){
System.out.println(inputan);
System.out.println(">>");
}
} catch (Exception 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();
WriteInput out = new WriteInput();
in.start();
out.start();
} catch (Exception e) {
System.out.println("Error");
}
}
}

21 changes: 21 additions & 0 deletions src/Driver/DriveClientConsole.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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 GL552JX
*/
public class DriveClientConsole {

public static void main(String[] args) {

ConsoleApplication ca = new ConsoleApplication();
ca.startChat();
}
}
20 changes: 20 additions & 0 deletions src/Driver/DriverClientGui.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 chatGUI.JChatController;

/**
*
* @author GL552JX
*/
public class DriverClientGui {

public static void main(String[] args) {

JChatController jcc = new JChatController();
}
}
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 javaChat.ServerConnection;

/**
*
* @author GL552JX
*/
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.start();
}
} catch (Exception e) {
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="txFieldChat" alignment="1" max="32767" attributes="0"/>
<Component id="jScrollPane1" alignment="0" pref="380" 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 min="-2" pref="16" max="-2" attributes="0"/>
<Component id="jScrollPane1" min="-2" pref="178" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="txFieldChat" min="-2" pref="45" max="-2" attributes="0"/>
<EmptySpace max="32767" 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">
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="txFieldChatActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>
Loading