├── Proyecto Java - chat ├── build.xml ├── build │ ├── built-jar.properties │ └── classes │ │ ├── Controlador │ │ ├── DAO.class │ │ ├── Launcher.class │ │ ├── threadCliente.class │ │ └── threadServidor.class │ │ ├── Modelo │ │ ├── Cliente.class │ │ ├── Emoji.class │ │ └── Emoji_Modelo.class │ │ └── Vista │ │ ├── Login$1.class │ │ ├── Login$2.class │ │ ├── Login$3.class │ │ ├── Login.class │ │ ├── Menu$1.class │ │ ├── Menu$2.class │ │ ├── Menu$3.class │ │ ├── Menu.class │ │ ├── Servidor.class │ │ ├── VentanaCliente$1.class │ │ ├── VentanaCliente$2.class │ │ ├── VentanaCliente$3.class │ │ ├── VentanaCliente$4.class │ │ ├── VentanaCliente$5.class │ │ ├── VentanaCliente$6.class │ │ ├── VentanaCliente.class │ │ ├── VentanaPrivada$1.class │ │ ├── VentanaPrivada$2.class │ │ └── VentanaPrivada.class ├── manifest.mf ├── nbproject │ ├── build-impl.xml │ ├── genfiles.properties │ ├── private │ │ ├── private.properties │ │ └── private.xml │ ├── project.properties │ └── project.xml └── src │ ├── Controlador │ ├── DAO.java │ ├── threadCliente.java │ └── threadServidor.java │ ├── Emojis_Images │ ├── 1.png │ ├── 10.png │ ├── 11.png │ ├── 12.png │ ├── 13.png │ ├── 14.png │ ├── 15.png │ ├── 16.png │ ├── 17.png │ ├── 18.png │ ├── 19.png │ ├── 2.png │ ├── 20.png │ ├── 21.png │ ├── 22.png │ ├── 23.png │ ├── 24.png │ ├── 25.png │ ├── 26.png │ ├── 27.png │ ├── 28.png │ ├── 29.png │ ├── 3.png │ ├── 30.png │ ├── 31.png │ ├── 32.png │ ├── 33.png │ ├── 34.png │ ├── 35.png │ ├── 36.png │ ├── 37.png │ ├── 38.png │ ├── 39.png │ ├── 4.png │ ├── 40.png │ ├── 5.png │ ├── 6.png │ ├── 7.png │ ├── 8.png │ └── 9.png │ ├── Modelo │ └── Cliente.java │ └── Vista │ ├── Login.form │ ├── Login.java │ ├── Servidor.java │ ├── VentanaAyuda.java │ ├── VentanaCliente.form │ ├── VentanaCliente.java │ ├── VentanaPrivada.form │ └── VentanaPrivada.java └── README.md /Proyecto Java - chat/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Builds, tests, and runs the project PA_Parcial2. 12 | 13 | 73 | 74 | -------------------------------------------------------------------------------- /Proyecto Java - chat/build/built-jar.properties: -------------------------------------------------------------------------------- 1 | #Thu, 24 Nov 2022 08:32:03 -0500 2 | 3 | 4 | C\:\\Users\\santi\\Desktop\\finalll\\PA_Parcial2= 5 | -------------------------------------------------------------------------------- /Proyecto Java - chat/build/classes/Controlador/DAO.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/build/classes/Controlador/DAO.class -------------------------------------------------------------------------------- /Proyecto Java - chat/build/classes/Controlador/Launcher.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/build/classes/Controlador/Launcher.class -------------------------------------------------------------------------------- /Proyecto Java - chat/build/classes/Controlador/threadCliente.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/build/classes/Controlador/threadCliente.class -------------------------------------------------------------------------------- /Proyecto Java - chat/build/classes/Controlador/threadServidor.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/build/classes/Controlador/threadServidor.class -------------------------------------------------------------------------------- /Proyecto Java - chat/build/classes/Modelo/Cliente.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/build/classes/Modelo/Cliente.class -------------------------------------------------------------------------------- /Proyecto Java - chat/build/classes/Modelo/Emoji.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/build/classes/Modelo/Emoji.class -------------------------------------------------------------------------------- /Proyecto Java - chat/build/classes/Modelo/Emoji_Modelo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/build/classes/Modelo/Emoji_Modelo.class -------------------------------------------------------------------------------- /Proyecto Java - chat/build/classes/Vista/Login$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/build/classes/Vista/Login$1.class -------------------------------------------------------------------------------- /Proyecto Java - chat/build/classes/Vista/Login$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/build/classes/Vista/Login$2.class -------------------------------------------------------------------------------- /Proyecto Java - chat/build/classes/Vista/Login$3.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/build/classes/Vista/Login$3.class -------------------------------------------------------------------------------- /Proyecto Java - chat/build/classes/Vista/Login.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/build/classes/Vista/Login.class -------------------------------------------------------------------------------- /Proyecto Java - chat/build/classes/Vista/Menu$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/build/classes/Vista/Menu$1.class -------------------------------------------------------------------------------- /Proyecto Java - chat/build/classes/Vista/Menu$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/build/classes/Vista/Menu$2.class -------------------------------------------------------------------------------- /Proyecto Java - chat/build/classes/Vista/Menu$3.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/build/classes/Vista/Menu$3.class -------------------------------------------------------------------------------- /Proyecto Java - chat/build/classes/Vista/Menu.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/build/classes/Vista/Menu.class -------------------------------------------------------------------------------- /Proyecto Java - chat/build/classes/Vista/Servidor.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/build/classes/Vista/Servidor.class -------------------------------------------------------------------------------- /Proyecto Java - chat/build/classes/Vista/VentanaCliente$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/build/classes/Vista/VentanaCliente$1.class -------------------------------------------------------------------------------- /Proyecto Java - chat/build/classes/Vista/VentanaCliente$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/build/classes/Vista/VentanaCliente$2.class -------------------------------------------------------------------------------- /Proyecto Java - chat/build/classes/Vista/VentanaCliente$3.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/build/classes/Vista/VentanaCliente$3.class -------------------------------------------------------------------------------- /Proyecto Java - chat/build/classes/Vista/VentanaCliente$4.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/build/classes/Vista/VentanaCliente$4.class -------------------------------------------------------------------------------- /Proyecto Java - chat/build/classes/Vista/VentanaCliente$5.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/build/classes/Vista/VentanaCliente$5.class -------------------------------------------------------------------------------- /Proyecto Java - chat/build/classes/Vista/VentanaCliente$6.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/build/classes/Vista/VentanaCliente$6.class -------------------------------------------------------------------------------- /Proyecto Java - chat/build/classes/Vista/VentanaCliente.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/build/classes/Vista/VentanaCliente.class -------------------------------------------------------------------------------- /Proyecto Java - chat/build/classes/Vista/VentanaPrivada$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/build/classes/Vista/VentanaPrivada$1.class -------------------------------------------------------------------------------- /Proyecto Java - chat/build/classes/Vista/VentanaPrivada$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/build/classes/Vista/VentanaPrivada$2.class -------------------------------------------------------------------------------- /Proyecto Java - chat/build/classes/Vista/VentanaPrivada.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/build/classes/Vista/VentanaPrivada.class -------------------------------------------------------------------------------- /Proyecto Java - chat/manifest.mf: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | X-COMMENT: Main-Class will be added automatically by build 3 | 4 | -------------------------------------------------------------------------------- /Proyecto Java - chat/nbproject/genfiles.properties: -------------------------------------------------------------------------------- 1 | build.xml.data.CRC32=2b05f603 2 | build.xml.script.CRC32=0fedfe39 3 | build.xml.stylesheet.CRC32=f85dc8f2@1.103.0.48 4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. 5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. 6 | nbproject/build-impl.xml.data.CRC32=2b05f603 7 | nbproject/build-impl.xml.script.CRC32=5e03ac71 8 | nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.103.0.48 9 | -------------------------------------------------------------------------------- /Proyecto Java - chat/nbproject/private/private.properties: -------------------------------------------------------------------------------- 1 | file.reference.mysql-connector-j-8.0.31.jar=C:\\Users\\Mauricio\\Downloads\\mysql-connector-j-8.0.31\\mysql-connector-j-8.0.31.jar 2 | user.properties.file=C:\\Users\\santi\\AppData\\Roaming\\NetBeans\\14\\build.properties 3 | -------------------------------------------------------------------------------- /Proyecto Java - chat/nbproject/private/private.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | file:/C:/Users/santi/Desktop/finalll/PA_Parcial2/src/Modelo/Cliente.java 7 | file:/C:/Users/santi/Desktop/finalll/PA_Parcial2/src/Controlador/threadServidor.java 8 | file:/C:/Users/santi/Desktop/finalll/PA_Parcial2/src/Controlador/threadCliente.java 9 | file:/C:/Users/santi/Desktop/finalll/PA_Parcial2/src/Vista/VentanaCliente.java 10 | file:/C:/Users/santi/Desktop/finalll/PA_Parcial2/src/Vista/Login.java 11 | file:/C:/Users/santi/Desktop/finalll/PA_Parcial2/src/Vista/VentanaAyuda.java 12 | file:/C:/Users/santi/Desktop/finalll/PA_Parcial2/src/Vista/Servidor.java 13 | file:/C:/Users/santi/Desktop/finalll/PA_Parcial2/src/Controlador/DAO.java 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Proyecto Java - chat/nbproject/project.properties: -------------------------------------------------------------------------------- 1 | annotation.processing.enabled=true 2 | annotation.processing.enabled.in.editor=false 3 | annotation.processing.processor.options= 4 | annotation.processing.processors.list= 5 | annotation.processing.run.all.processors=true 6 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output 7 | build.classes.dir=${build.dir}/classes 8 | build.classes.excludes=**/*.java,**/*.form 9 | # This directory is removed when the project is cleaned: 10 | build.dir=build 11 | build.generated.dir=${build.dir}/generated 12 | build.generated.sources.dir=${build.dir}/generated-sources 13 | # Only compile against the classpath explicitly listed here: 14 | build.sysclasspath=ignore 15 | build.test.classes.dir=${build.dir}/test/classes 16 | build.test.results.dir=${build.dir}/test/results 17 | # Uncomment to specify the preferred debugger connection transport: 18 | #debug.transport=dt_socket 19 | debug.classpath=\ 20 | ${run.classpath} 21 | debug.modulepath=\ 22 | ${run.modulepath} 23 | debug.test.classpath=\ 24 | ${run.test.classpath} 25 | debug.test.modulepath=\ 26 | ${run.test.modulepath} 27 | # Files in build.classes.dir which should be excluded from distribution jar 28 | dist.archive.excludes= 29 | # This directory is removed when the project is cleaned: 30 | dist.dir=dist 31 | dist.jar=${dist.dir}/PA_Parcial2.jar 32 | dist.javadoc.dir=${dist.dir}/javadoc 33 | dist.jlink.dir=${dist.dir}/jlink 34 | dist.jlink.output=${dist.jlink.dir}/PA_Parcial2 35 | excludes= 36 | file.reference.mysql-connector-j-8.0.31.jar=C:\\Users\\santi\\Documents\\derby\\mysql-connector-j-8.0.31.jar 37 | file.reference.mysql-connector-j-8.0.31.jar-1=C:\\Users\\santi\\Documents\\derby\\mysql-connector-j-8.0.31.jar 38 | includes=** 39 | jar.compress=false 40 | javac.classpath=\ 41 | ${file.reference.mysql-connector-j-8.0.31.jar}:\ 42 | ${file.reference.mysql-connector-j-8.0.31.jar-1} 43 | # Space-separated list of extra javac options 44 | javac.compilerargs= 45 | javac.deprecation=false 46 | javac.external.vm=true 47 | javac.modulepath= 48 | javac.processormodulepath= 49 | javac.processorpath=\ 50 | ${javac.classpath} 51 | javac.source=18 52 | javac.target=18 53 | javac.test.classpath=\ 54 | ${javac.classpath}:\ 55 | ${build.classes.dir} 56 | javac.test.modulepath=\ 57 | ${javac.modulepath} 58 | javac.test.processorpath=\ 59 | ${javac.test.classpath} 60 | javadoc.additionalparam= 61 | javadoc.author=false 62 | javadoc.encoding=${source.encoding} 63 | javadoc.html5=false 64 | javadoc.noindex=false 65 | javadoc.nonavbar=false 66 | javadoc.notree=false 67 | javadoc.private=false 68 | javadoc.splitindex=true 69 | javadoc.use=true 70 | javadoc.version=false 71 | javadoc.windowtitle= 72 | # The jlink additional root modules to resolve 73 | jlink.additionalmodules= 74 | # The jlink additional command line parameters 75 | jlink.additionalparam= 76 | jlink.launcher=true 77 | jlink.launcher.name=PA_Parcial2 78 | main.class=Controlador.Launcher 79 | manifest.file=manifest.mf 80 | meta.inf.dir=${src.dir}/META-INF 81 | mkdist.disabled=false 82 | platform.active=default_platform 83 | run.classpath=\ 84 | ${javac.classpath}:\ 85 | ${build.classes.dir} 86 | # Space-separated list of JVM arguments used when running the project. 87 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. 88 | # To set system properties for unit tests define test-sys-prop.name=value: 89 | run.jvmargs= 90 | run.modulepath=\ 91 | ${javac.modulepath} 92 | run.test.classpath=\ 93 | ${javac.test.classpath}:\ 94 | ${build.test.classes.dir} 95 | run.test.modulepath=\ 96 | ${javac.test.modulepath} 97 | source.encoding=UTF-8 98 | src.dir=src 99 | test.src.dir=test 100 | -------------------------------------------------------------------------------- /Proyecto Java - chat/nbproject/project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.netbeans.modules.java.j2seproject 4 | 5 | 6 | PA_Parcial2 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Controlador/DAO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license 3 | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template 4 | */ 5 | package Controlador; 6 | 7 | import java.sql.Connection; 8 | import java.sql.DriverManager; 9 | import java.sql.SQLException; 10 | import java.beans.Statement; 11 | import java.sql.Connection; 12 | import java.sql.DriverManager; 13 | import java.sql.SQLException; 14 | import javax.swing.table.DefaultTableModel; 15 | import java.sql.PreparedStatement; 16 | import java.sql.ResultSet; 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | import java.util.logging.Level; 20 | import java.util.logging.Logger; 21 | import javax.swing.JOptionPane; 22 | 23 | /** 24 | * 25 | * @author Santiago Baron Zuleta, Mauricio Sanchez, Sebastian Yepes 26 | */ 27 | public class DAO { 28 | 29 | private Statement consulta = null; 30 | private String db = "segundoparcial_db"; 31 | private String url = "jdbc:mysql://localhost/"; 32 | private String user = "root"; 33 | private String password = ""; 34 | private String driver = "com.mysql.cj.jdbc.Driver"; 35 | private Connection cx; 36 | 37 | public DAO() { 38 | 39 | } 40 | 41 | public Connection conectar() { 42 | 43 | try { 44 | Class.forName(driver); 45 | cx = DriverManager.getConnection(url + db, user, password); 46 | } catch (SQLException | ClassNotFoundException ex) { 47 | System.out.println("No se conecto a base de datos" + ex); 48 | } 49 | 50 | return cx; 51 | 52 | } 53 | 54 | public void desconectar() { 55 | try { 56 | cx.close(); 57 | } catch (SQLException ex) { 58 | System.out.println("No se pudo conectar"); 59 | } 60 | } 61 | 62 | public boolean validarUsuario(String user) { 63 | boolean comprobacion = false; 64 | 65 | String sql = "SELECT * FROM users WHERE usuario='" + user + "'"; 66 | 67 | try { 68 | Connection cn = this.conectar(); 69 | PreparedStatement pst = cn.prepareStatement(sql); 70 | ResultSet rs = pst.executeQuery(); 71 | 72 | if (rs.next()) { 73 | comprobacion = true; 74 | } else { 75 | comprobacion = false; 76 | JOptionPane.showMessageDialog(null, "El usuario: " + user + " no existe"); 77 | } 78 | 79 | cn.close(); 80 | 81 | } catch (SQLException e) { 82 | JOptionPane.showMessageDialog(null, "La verificación no se ha completado"); 83 | } 84 | 85 | return comprobacion; 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Controlador/threadCliente.java: -------------------------------------------------------------------------------- 1 | package Controlador; 2 | 3 | import Vista.VentanaCliente; 4 | import Vista.VentanaCliente; 5 | import java.net.*; 6 | import java.lang.*; 7 | import java.io.*; 8 | import java.util.*; 9 | import java.util.logging.Level; 10 | import java.util.logging.Logger; 11 | 12 | /** 13 | * 14 | * @author Santiago Baron Zuleta, Mauricio Sanchez, Sebastian Yepes 15 | */ 16 | 17 | public class threadCliente extends Thread { 18 | 19 | DataInputStream entrada; 20 | VentanaCliente vcli; 21 | 22 | public threadCliente(DataInputStream entrada, VentanaCliente vcli) throws IOException { 23 | this.entrada = entrada; 24 | this.vcli = vcli; 25 | } 26 | 27 | public void run() { 28 | String menser = "", amigo = ""; 29 | int opcion = 0; 30 | while (true) { 31 | 32 | try { 33 | opcion = entrada.readInt(); 34 | switch (opcion) { 35 | case 1://mensage enviado 36 | menser = entrada.readUTF(); 37 | System.out.println("ECO del servidor:" + menser); 38 | vcli.mostrarMsg(menser); 39 | break; 40 | case 2://se agrega 41 | menser = entrada.readUTF(); 42 | vcli.agregarUser(menser); 43 | break; 44 | case 3://mensage de amigo 45 | amigo = entrada.readUTF(); 46 | menser = entrada.readUTF(); 47 | vcli.mensageAmigo(amigo, menser); 48 | System.out.println("ECO del servidor:" + menser); 49 | break; 50 | case 4: 51 | menser = entrada.readUTF(); 52 | vcli.enviarMensaje("He sido bloqueado de este chat ¡Adioooos!"); 53 | vcli.bloquear(); 54 | break; 55 | } 56 | } catch (IOException e) { 57 | System.out.println("Error en la comunicaci�n " + "Informaci�n para el usuario"); 58 | break; 59 | } 60 | } 61 | System.out.println("se desconecto el servidor"); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Controlador/threadServidor.java: -------------------------------------------------------------------------------- 1 | package Controlador; 2 | 3 | /* 4 | * threadServidor.java 5 | * 6 | * Created on 23 de marzo de 2008, 19:36 7 | * 8 | * To change this template, choose Tools | Template Manager 9 | * and open the template in the editor. 10 | */ 11 | import Vista.Servidor; 12 | import Vista.VentanaCliente; 13 | import java.awt.*; 14 | import java.io.*; 15 | import java.net.*; 16 | import java.util.*; 17 | import javax.swing.*; 18 | 19 | /** 20 | * 21 | * @author Santiago Baron Zuleta, Mauricio Sanchez, Sebastian Yepes 22 | */ 23 | public class threadServidor extends Thread { 24 | 25 | Socket scli = null; 26 | Socket scli2 = null; 27 | DataInputStream entrada = null; 28 | DataOutputStream salida = null; 29 | DataOutputStream salida2 = null; 30 | public static Vector clientesActivos = new Vector(); 31 | String nameUser; 32 | Servidor serv; 33 | 34 | public threadServidor(Socket scliente, Socket scliente2, Servidor serv) { 35 | scli = scliente; 36 | scli2 = scliente2; 37 | this.serv = serv; 38 | nameUser = ""; 39 | clientesActivos.add(this); 40 | serv.mostrar("cliente agregado: " + this); 41 | } 42 | 43 | public String getNameUser() { 44 | return nameUser; 45 | } 46 | 47 | public void setNameUser(String name) { 48 | nameUser = name; 49 | } 50 | 51 | public void run() { 52 | serv.mostrar(".::Esperando Mensajes :"); 53 | 54 | try { 55 | entrada = new DataInputStream(scli.getInputStream()); 56 | salida = new DataOutputStream(scli.getOutputStream()); 57 | salida2 = new DataOutputStream(scli2.getOutputStream()); 58 | this.setNameUser(entrada.readUTF()); 59 | enviaUserActivos(); 60 | } catch (IOException e) { 61 | e.printStackTrace(); 62 | } 63 | 64 | int opcion = 0, numUsers = 0; 65 | String amigo = "", mencli = "", userBloquear = ""; 66 | 67 | while (true) { 68 | try { 69 | 70 | String name_to_block = serv.usuarioBloquear; 71 | 72 | if (name_to_block != "") { 73 | opcion = 4; 74 | } else { 75 | opcion = entrada.readInt(); 76 | } 77 | 78 | switch (opcion) { 79 | case 1://envio de mensage a todos 80 | mencli = entrada.readUTF(); 81 | serv.mostrar(getNameUser() + ": " + mencli); 82 | enviaMsg(mencli); 83 | break; 84 | case 2://envio de lista de activos 85 | numUsers = clientesActivos.size(); 86 | salida.writeInt(numUsers); 87 | for (int i = 0; i < numUsers; i++) { 88 | salida.writeUTF(clientesActivos.get(i).nameUser); 89 | } 90 | break; 91 | case 3: // envia mensage a uno solo 92 | amigo = entrada.readUTF();//captura nombre de amigo 93 | mencli = entrada.readUTF();//mensage enviado 94 | enviaMsg(amigo, mencli); 95 | break; 96 | case 4: // Bloquea al usuario 97 | userBloquear = name_to_block; 98 | serv.mostrar(name_to_block); 99 | serv.mostrar("Se ha bloqueado al usuario: " + name_to_block); 100 | bloquearUsuario(userBloquear); 101 | serv.usuarioBloquear = name_to_block = ""; 102 | opcion = 0; 103 | break; 104 | } 105 | } catch (IOException e) { 106 | System.out.println("El cliente termino la conexion"); 107 | break; 108 | } 109 | } 110 | serv.mostrar("Se removio un usuario: "); 111 | clientesActivos.removeElement(this); 112 | 113 | try { 114 | serv.mostrar("Se desconecto un usuario"); 115 | scli.close(); 116 | } catch (Exception et) { 117 | serv.mostrar("no se puede cerrar el socket"); 118 | } 119 | } 120 | 121 | public void bloquearUsuario(String usuario) throws IOException { 122 | threadServidor user = null; 123 | for (int i = 0; i < clientesActivos.size(); i++) { 124 | try { 125 | if (clientesActivos.get(i).getNameUser().equals(usuario)) { 126 | user = clientesActivos.get(i); 127 | user.salida2.writeInt(4);//opcion de mensage 128 | user.salida2.writeUTF(usuario); 129 | serv.usuarioBloquear = ""; 130 | } 131 | 132 | } catch (IOException e) { 133 | e.printStackTrace(); 134 | } 135 | } 136 | } 137 | 138 | public void enviaMsg(String mencli2) { 139 | threadServidor user = null; 140 | for (int i = 0; i < clientesActivos.size(); i++) { 141 | serv.mostrar("MENSAJE DEVUELTO:" + mencli2); 142 | try { 143 | user = clientesActivos.get(i); 144 | user.salida2.writeInt(1);//opcion de mensage 145 | user.salida2.writeUTF("" + this.getNameUser() + ": " + mencli2); 146 | } catch (IOException e) { 147 | e.printStackTrace(); 148 | } 149 | } 150 | } 151 | 152 | public void enviaUserActivos() { 153 | threadServidor user = null; 154 | for (int i = 0; i < clientesActivos.size(); i++) { 155 | try { 156 | user = clientesActivos.get(i); 157 | if (user == this) { 158 | continue;//ya se lo envie 159 | } 160 | user.salida2.writeInt(2);//opcion de agregar 161 | user.salida2.writeUTF(this.getNameUser()); 162 | } catch (IOException e) { 163 | e.printStackTrace(); 164 | } 165 | } 166 | } 167 | 168 | private void enviaMsg(String amigo, String mencli) { 169 | threadServidor user = null; 170 | for (int i = 0; i < clientesActivos.size(); i++) { 171 | try { 172 | user = clientesActivos.get(i); 173 | if (user.nameUser.equals(amigo)) { 174 | user.salida2.writeInt(3);//opcion de mensage amigo 175 | user.salida2.writeUTF(this.getNameUser()); 176 | user.salida2.writeUTF("" + this.getNameUser() + ": " + mencli); 177 | } 178 | } catch (IOException e) { 179 | e.printStackTrace(); 180 | } 181 | } 182 | } 183 | } 184 | -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/1.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/10.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/11.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/12.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/13.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/14.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/15.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/16.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/17.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/18.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/19.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/2.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/20.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/21.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/22.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/23.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/24.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/25.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/26.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/27.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/27.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/28.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/29.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/3.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/30.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/31.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/31.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/32.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/33.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/33.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/34.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/34.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/35.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/35.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/36.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/36.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/37.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/37.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/38.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/38.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/39.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/39.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/4.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/40.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/5.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/6.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/7.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/8.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Emojis_Images/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/santiagobaronz/java-chat/f79bbfdb3f8200f026f2df75ae0897e6c22455f1/Proyecto Java - chat/src/Emojis_Images/9.png -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Modelo/Cliente.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Cliente.java 3 | * 4 | * Created on 21 de marzo de 2008, 12:11 PM 5 | * 6 | * To change this template, choose Tools | Template Manager 7 | * and open the template in the editor. 8 | */ 9 | package Modelo; 10 | 11 | import Controlador.threadCliente; 12 | import Vista.VentanaCliente; 13 | import java.io.*; 14 | import java.net.*; 15 | import java.util.Vector; 16 | import java.util.logging.Level; 17 | import java.util.logging.Logger; 18 | import javax.swing.JOptionPane; 19 | 20 | /** 21 | * 22 | * @author Santiago Baron Zuleta, Mauricio Sanchez, Sebastian Yepes 23 | */ 24 | public class Cliente { 25 | 26 | public static String IP_SERVER; 27 | VentanaCliente vent; 28 | DataInputStream entrada = null; 29 | DataOutputStream salida = null; 30 | DataInputStream entrada2 = null; 31 | Socket comunication = null;//para la comunicacion 32 | Socket comunication2 = null;//para recivir msg 33 | 34 | String nomCliente; 35 | private String user; 36 | 37 | /** 38 | * Creates a new instance of Cliente 39 | */ 40 | public Cliente(VentanaCliente vent) throws IOException { 41 | this.vent = vent; 42 | } 43 | 44 | public Cliente() { 45 | } 46 | 47 | public void conexion(String user) throws IOException { 48 | try { 49 | comunication = new Socket(Cliente.IP_SERVER, 8081); 50 | comunication2 = new Socket(Cliente.IP_SERVER, 8082); 51 | entrada = new DataInputStream(comunication.getInputStream()); 52 | salida = new DataOutputStream(comunication.getOutputStream()); 53 | entrada2 = new DataInputStream(comunication2.getInputStream()); 54 | nomCliente = user; 55 | vent.setNombreUser(user); 56 | salida.writeUTF(nomCliente); 57 | } catch (IOException e) { 58 | JOptionPane.showMessageDialog(null, "El servidor en esa ip servidor no esta levantado"); 59 | } 60 | new threadCliente(entrada2, vent).start(); 61 | } 62 | 63 | public String getNombre() { 64 | return nomCliente; 65 | } 66 | 67 | public Vector pedirUsuarios() { 68 | Vector users = new Vector(); 69 | try { 70 | salida.writeInt(2); 71 | int numUsers = entrada.readInt(); 72 | for (int i = 0; i < numUsers; i++) { 73 | users.add(entrada.readUTF()); 74 | } 75 | } catch (IOException ex) { 76 | System.err.println("Ha ocurrido un error"); 77 | } 78 | return users; 79 | } 80 | 81 | public void flujo(String mens) { 82 | try { 83 | System.out.println(getNombre() + ":" 84 | + mens); 85 | salida.writeInt(1); 86 | salida.writeUTF(mens); 87 | } catch (IOException e) { 88 | System.out.println("error...." + e); 89 | } 90 | } 91 | 92 | public void flujo(String amigo, String mens) { 93 | try { 94 | System.out.println(getNombre() + ":" 95 | + mens); 96 | salida.writeInt(3);//opcion de mensage a amigo 97 | salida.writeUTF(amigo); 98 | salida.writeUTF(mens); 99 | } catch (IOException e) { 100 | System.out.println("error...." + e); 101 | } 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Vista/Login.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Vista/Login.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license 3 | * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template 4 | */ 5 | package Vista; 6 | 7 | import Controlador.DAO; 8 | import Modelo.Cliente; 9 | import java.io.IOException; 10 | import java.util.logging.Level; 11 | import java.util.logging.Logger; 12 | import javax.swing.JOptionPane; 13 | 14 | /** 15 | * 16 | * @author Santiago Baron Zuleta, Mauricio Sanchez, Sebastian Yepes 17 | */ 18 | public class Login extends javax.swing.JFrame { 19 | 20 | /** 21 | * Creates new form Login 22 | */ 23 | public Login() { 24 | initComponents(); 25 | this.setTitle("Iniciar sesión"); 26 | } 27 | 28 | /** 29 | * This method is called from within the constructor to initialize the form. 30 | * WARNING: Do NOT modify this code. The content of this method is always 31 | * regenerated by the Form Editor. 32 | */ 33 | @SuppressWarnings("unchecked") 34 | // //GEN-BEGIN:initComponents 35 | private void initComponents() { 36 | 37 | jPanel1 = new javax.swing.JPanel(); 38 | jLabel1 = new javax.swing.JLabel(); 39 | jLabel2 = new javax.swing.JLabel(); 40 | server_ip = new javax.swing.JTextField(); 41 | jLabel3 = new javax.swing.JLabel(); 42 | username = new javax.swing.JTextField(); 43 | jButton1 = new javax.swing.JButton(); 44 | 45 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 46 | 47 | jPanel1.setBackground(new java.awt.Color(13, 19, 35)); 48 | 49 | jLabel1.setFont(new java.awt.Font("Poppins", 1, 24)); // NOI18N 50 | jLabel1.setForeground(new java.awt.Color(255, 255, 255)); 51 | jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); 52 | jLabel1.setText("Inicio de sesión"); 53 | 54 | jLabel2.setFont(new java.awt.Font("Poppins", 0, 14)); // NOI18N 55 | jLabel2.setForeground(new java.awt.Color(255, 255, 255)); 56 | jLabel2.setText("Nombre de usuario"); 57 | 58 | server_ip.setBackground(new java.awt.Color(32, 42, 54)); 59 | server_ip.setFont(new java.awt.Font("Poppins", 0, 14)); // NOI18N 60 | server_ip.setForeground(new java.awt.Color(255, 255, 255)); 61 | server_ip.setMargin(new java.awt.Insets(0, 10, 0, 0)); 62 | 63 | jLabel3.setFont(new java.awt.Font("Poppins", 0, 14)); // NOI18N 64 | jLabel3.setForeground(new java.awt.Color(255, 255, 255)); 65 | jLabel3.setText("Servidor a conectar"); 66 | 67 | username.setBackground(new java.awt.Color(32, 42, 54)); 68 | username.setFont(new java.awt.Font("Poppins", 0, 14)); // NOI18N 69 | username.setForeground(new java.awt.Color(255, 255, 255)); 70 | username.setMargin(new java.awt.Insets(0, 10, 0, 0)); 71 | username.addActionListener(new java.awt.event.ActionListener() { 72 | public void actionPerformed(java.awt.event.ActionEvent evt) { 73 | usernameActionPerformed(evt); 74 | } 75 | }); 76 | 77 | jButton1.setBackground(new java.awt.Color(102, 16, 242)); 78 | jButton1.setFont(new java.awt.Font("Poppins", 1, 14)); // NOI18N 79 | jButton1.setForeground(new java.awt.Color(255, 255, 255)); 80 | jButton1.setText("Iniciar sesión"); 81 | jButton1.addActionListener(new java.awt.event.ActionListener() { 82 | public void actionPerformed(java.awt.event.ActionEvent evt) { 83 | jButton1ActionPerformed(evt); 84 | } 85 | }); 86 | 87 | javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); 88 | jPanel1.setLayout(jPanel1Layout); 89 | jPanel1Layout.setHorizontalGroup( 90 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 91 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() 92 | .addContainerGap() 93 | .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 418, Short.MAX_VALUE) 94 | .addContainerGap()) 95 | .addGroup(jPanel1Layout.createSequentialGroup() 96 | .addGap(37, 37, 37) 97 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) 98 | .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 351, Short.MAX_VALUE) 99 | .addComponent(username) 100 | .addComponent(jLabel3) 101 | .addComponent(server_ip) 102 | .addComponent(jLabel2)) 103 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 104 | ); 105 | jPanel1Layout.setVerticalGroup( 106 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 107 | .addGroup(jPanel1Layout.createSequentialGroup() 108 | .addGap(36, 36, 36) 109 | .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) 110 | .addGap(37, 37, 37) 111 | .addComponent(jLabel2) 112 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 113 | .addComponent(username, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE) 114 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) 115 | .addComponent(jLabel3) 116 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 117 | .addComponent(server_ip, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE) 118 | .addGap(38, 38, 38) 119 | .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE) 120 | .addContainerGap(46, Short.MAX_VALUE)) 121 | ); 122 | 123 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 124 | getContentPane().setLayout(layout); 125 | layout.setHorizontalGroup( 126 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 127 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 128 | ); 129 | layout.setVerticalGroup( 130 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 131 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 132 | ); 133 | 134 | pack(); 135 | setLocationRelativeTo(null); 136 | }// //GEN-END:initComponents 137 | 138 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed 139 | 140 | String user = this.username.getText(); 141 | 142 | DAO validacion = new DAO(); 143 | boolean estado = validacion.validarUsuario(user); 144 | 145 | if (estado) { 146 | VentanaCliente cliente; 147 | try { 148 | Cliente.IP_SERVER = this.server_ip.getText(); 149 | cliente = new VentanaCliente(user); 150 | cliente.setVisible(true); 151 | this.setVisible(false); 152 | } catch (IOException ex) { 153 | Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex); 154 | } 155 | } 156 | 157 | }//GEN-LAST:event_jButton1ActionPerformed 158 | 159 | private void usernameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_usernameActionPerformed 160 | // TODO add your handling code here: 161 | }//GEN-LAST:event_usernameActionPerformed 162 | 163 | /** 164 | * @param args the command line arguments 165 | */ 166 | public static void main(String args[]) { 167 | /* Set the Nimbus look and feel */ 168 | // 169 | /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. 170 | * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 171 | */ 172 | try { 173 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { 174 | if ("Nimbus".equals(info.getName())) { 175 | javax.swing.UIManager.setLookAndFeel(info.getClassName()); 176 | break; 177 | } 178 | } 179 | } catch (ClassNotFoundException ex) { 180 | java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 181 | } catch (InstantiationException ex) { 182 | java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 183 | } catch (IllegalAccessException ex) { 184 | java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 185 | } catch (javax.swing.UnsupportedLookAndFeelException ex) { 186 | java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 187 | } 188 | // 189 | 190 | /* Create and display the form */ 191 | java.awt.EventQueue.invokeLater(new Runnable() { 192 | public void run() { 193 | new Login().setVisible(true); 194 | } 195 | }); 196 | } 197 | 198 | // Variables declaration - do not modify//GEN-BEGIN:variables 199 | private javax.swing.JButton jButton1; 200 | private javax.swing.JLabel jLabel1; 201 | private javax.swing.JLabel jLabel2; 202 | private javax.swing.JLabel jLabel3; 203 | private javax.swing.JPanel jPanel1; 204 | public javax.swing.JTextField server_ip; 205 | public javax.swing.JTextField username; 206 | // End of variables declaration//GEN-END:variables 207 | } 208 | -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Vista/Servidor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Server.java 3 | * 4 | * Created on 21 de marzo de 2008, 12:02 PM 5 | * 6 | * To change this template, choose Tools | Template Manager 7 | * and open the template in the editor. 8 | */ 9 | package Vista; 10 | 11 | /** 12 | * 13 | * @author Santiago Baron Zuleta, Mauricio Sanchez, Sebastian Yepes 14 | */ 15 | import Controlador.threadServidor; 16 | import Modelo.Cliente; 17 | import Vista.VentanaCliente; 18 | import java.awt.*; 19 | import java.awt.event.ActionEvent; 20 | import java.awt.event.ActionListener; 21 | import java.io.*; 22 | import java.net.*; 23 | import java.util.*; 24 | import javax.swing.*; 25 | 26 | public class Servidor extends JFrame implements ActionListener { 27 | 28 | // DECLARAMOS ELEMENTOS 29 | JTextArea txaMostrar; 30 | JButton butBlq; 31 | JTextField userBlq; 32 | 33 | public Servidor() { 34 | super("Consola servidor"); 35 | txaMostrar = new JTextArea(); 36 | setLocationRelativeTo(null); 37 | userBlq = new JTextField(30); 38 | butBlq = new JButton("Bloquear"); 39 | butBlq.addActionListener(this); 40 | 41 | txaMostrar = new JTextArea(); 42 | txaMostrar.setColumns(25); 43 | 44 | txaMostrar.setEditable(false); 45 | txaMostrar.setForeground(Color.BLUE); 46 | txaMostrar.setBorder(javax.swing.BorderFactory.createMatteBorder(3, 3, 3, 3, new Color(25, 10, 80))); 47 | 48 | JPanel panAbajo = new JPanel(); 49 | panAbajo.setLayout(new BorderLayout()); 50 | panAbajo.add(new JLabel(" Ingrese usuario a bloquear: "), BorderLayout.WEST); 51 | panAbajo.add(userBlq, BorderLayout.CENTER); 52 | panAbajo.add(butBlq, BorderLayout.EAST); 53 | 54 | JPanel panArriba = new JPanel(); 55 | panArriba.setLayout(new BorderLayout()); 56 | panArriba.add(new JScrollPane(txaMostrar), BorderLayout.CENTER); 57 | 58 | JPanel panCentral = new JPanel(); 59 | panCentral.setLayout(new BorderLayout()); 60 | panCentral.add(panAbajo, BorderLayout.SOUTH); 61 | panCentral.add(panArriba,BorderLayout.NORTH); 62 | 63 | setLayout(new BorderLayout()); 64 | add(panAbajo, BorderLayout.SOUTH); 65 | add(panArriba, BorderLayout.CENTER); 66 | 67 | userBlq.requestFocus();//pedir el focus 68 | 69 | setSize(450, 430); 70 | setLocation(120, 90); 71 | setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 72 | setVisible(true); 73 | 74 | } 75 | 76 | public void mostrar(String msg) { 77 | txaMostrar.append(msg + "\n"); 78 | } 79 | 80 | public String usuarioBloquear = ""; 81 | 82 | public void actionPerformed(ActionEvent e) { 83 | usuarioBloquear = this.userBlq.getText(); 84 | } 85 | 86 | public void runServer() { 87 | ServerSocket serv = null;//para comunicacion 88 | ServerSocket serv2 = null;//para enviar mensajes 89 | boolean listening = true; 90 | try { 91 | serv = new ServerSocket(8081); 92 | serv2 = new ServerSocket(8082); 93 | mostrar(".::Servidor activo :"); 94 | while (listening) { 95 | Socket sock = null, sock2 = null; 96 | try { 97 | mostrar("Esperando Usuarios"); 98 | sock = serv.accept(); 99 | sock2 = serv2.accept(); 100 | } catch (IOException e) { 101 | mostrar("Accept failed: " + serv + ", " + e.getMessage()); 102 | continue; 103 | } 104 | threadServidor user = new threadServidor(sock, sock2, this); 105 | user.start(); 106 | } 107 | 108 | } catch (IOException e) { 109 | mostrar("error :" + e); 110 | } 111 | } 112 | public static void main(String abc[]) throws IOException { 113 | Servidor ser = new Servidor(); 114 | ser.runServer(); 115 | } 116 | 117 | 118 | } 119 | -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Vista/VentanaAyuda.java: -------------------------------------------------------------------------------- 1 | /* 2 | * VentanaAyuda.java 3 | * 4 | * Created on 23 de marzo de 2008, 17:32 5 | * 6 | * To change this template, choose Tools | Template Manager 7 | * and open the template in the editor. 8 | */ 9 | package Vista; 10 | 11 | import javax.swing.*; 12 | import java.awt.event.*; 13 | import java.awt.*; 14 | import java.io.*; 15 | import java.lang.*; 16 | import java.util.*; 17 | import java.net.URL; 18 | 19 | /** 20 | * 21 | * @author Santiago Baron Zuleta, Mauricio Sanchez, Sebastian Yepes 22 | */ 23 | public class VentanaAyuda extends JFrame { 24 | 25 | /** 26 | * Creates a new instance of VentanaAyuda 27 | */ 28 | JScrollPane panelPrincipal; 29 | JEditorPane html; 30 | 31 | public VentanaAyuda() { 32 | super("Ventana de Ayuda :"); 33 | setSize(600, 700); 34 | setLocation(450, 0); 35 | panelPrincipal = new JScrollPane(); 36 | 37 | try { 38 | URL url = getClass().getResource("index.html"); 39 | html = new JEditorPane(url); 40 | html.setEditable(false); 41 | setVisible(true); 42 | 43 | } catch (Exception e) { 44 | e.getMessage(); 45 | } 46 | 47 | JViewport jv = panelPrincipal.getViewport(); 48 | jv.add(html); 49 | 50 | setContentPane(panelPrincipal); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Vista/VentanaCliente.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Vista/VentanaCliente.java: -------------------------------------------------------------------------------- 1 | package Vista; 2 | 3 | import Modelo.Cliente; 4 | import java.awt.BorderLayout; 5 | import java.awt.Color; 6 | import java.awt.Cursor; 7 | import java.awt.Font; 8 | import java.awt.event.ActionEvent; 9 | import java.awt.event.ActionListener; 10 | import java.io.*; 11 | import java.net.Socket; 12 | import java.util.Vector; 13 | import java.util.logging.Level; 14 | import java.util.logging.Logger; 15 | import javax.swing.*; 16 | import javax.swing.border.Border; 17 | import javax.swing.JOptionPane.*; 18 | import javax.swing.border.EmptyBorder; 19 | 20 | /* 21 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license 22 | * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template 23 | */ 24 | /** 25 | * 26 | * @author Santiago Baron Zuleta, Mauricio Sanchez, Sebastian Yepes 27 | */ 28 | public class VentanaCliente extends javax.swing.JFrame { 29 | 30 | /** 31 | * This method is called from within the constructor to initialize the form. 32 | * WARNING: Do NOT modify this code. The content of this method is always 33 | * regenerated by the Form Editor. 34 | */ 35 | @SuppressWarnings("unchecked") 36 | // //GEN-BEGIN:initComponents 37 | private void initComponents() { 38 | 39 | jPanel2 = new javax.swing.JPanel(); 40 | jPanel1 = new javax.swing.JPanel(); 41 | salir = new javax.swing.JButton(); 42 | jScrollPane2 = new javax.swing.JScrollPane(); 43 | lstActivos = new javax.swing.JList<>(); 44 | butPrivado = new javax.swing.JToggleButton(); 45 | users_conected = new javax.swing.JLabel(); 46 | txtMensage = new javax.swing.JTextField(); 47 | butEnviar = new javax.swing.JButton(); 48 | nombreGrandeUser = new javax.swing.JLabel(); 49 | jScrollPane1 = new javax.swing.JScrollPane(); 50 | panMostrar = new javax.swing.JTextArea(); 51 | 52 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 53 | setBackground(new java.awt.Color(255, 255, 255)); 54 | setLocation(new java.awt.Point(0, 0)); 55 | setMinimumSize(new java.awt.Dimension(1135, 730)); 56 | setResizable(false); 57 | setSize(new java.awt.Dimension(1200, 1200)); 58 | 59 | jPanel2.setBackground(new java.awt.Color(18, 26, 47)); 60 | jPanel2.setMinimumSize(new java.awt.Dimension(1120, 691)); 61 | 62 | jPanel1.setBackground(new java.awt.Color(13, 19, 35)); 63 | 64 | salir.setBackground(new java.awt.Color(102, 16, 242)); 65 | salir.setFont(new java.awt.Font("Poppins", 0, 14)); // NOI18N 66 | salir.setForeground(new java.awt.Color(255, 255, 255)); 67 | salir.setText("Cerrar sesión"); 68 | salir.addActionListener(new java.awt.event.ActionListener() { 69 | public void actionPerformed(java.awt.event.ActionEvent evt) { 70 | salirActionPerformed(evt); 71 | } 72 | }); 73 | 74 | lstActivos.setBackground(new java.awt.Color(23, 25, 55)); 75 | lstActivos.setFont(new java.awt.Font("Poppins", 0, 14)); // NOI18N 76 | lstActivos.setForeground(new java.awt.Color(255, 255, 255)); 77 | lstActivos.setModel(new javax.swing.AbstractListModel() { 78 | String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }; 79 | public int getSize() { return strings.length; } 80 | public String getElementAt(int i) { return strings[i]; } 81 | }); 82 | lstActivos.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); 83 | lstActivos.setDragEnabled(true); 84 | lstActivos.setFixedCellHeight(35); 85 | lstActivos.setName(""); // NOI18N 86 | jScrollPane2.setViewportView(lstActivos); 87 | 88 | butPrivado.setBackground(new java.awt.Color(102, 16, 242)); 89 | butPrivado.setFont(new java.awt.Font("Poppins", 0, 14)); // NOI18N 90 | butPrivado.setForeground(new java.awt.Color(255, 255, 255)); 91 | butPrivado.setText("Privado"); 92 | butPrivado.addActionListener(new java.awt.event.ActionListener() { 93 | public void actionPerformed(java.awt.event.ActionEvent evt) { 94 | butPrivadoActionPerformed(evt); 95 | } 96 | }); 97 | 98 | users_conected.setFont(new java.awt.Font("Poppins", 0, 16)); // NOI18N 99 | users_conected.setForeground(new java.awt.Color(255, 255, 255)); 100 | users_conected.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); 101 | users_conected.setText("Usuarios conectados"); 102 | 103 | javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); 104 | jPanel1.setLayout(jPanel1Layout); 105 | jPanel1Layout.setHorizontalGroup( 106 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 107 | .addGroup(jPanel1Layout.createSequentialGroup() 108 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 109 | .addGroup(jPanel1Layout.createSequentialGroup() 110 | .addGap(32, 32, 32) 111 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) 112 | .addComponent(butPrivado, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE) 113 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) 114 | .addComponent(jScrollPane2) 115 | .addComponent(salir, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)))) 116 | .addGroup(jPanel1Layout.createSequentialGroup() 117 | .addGap(23, 23, 23) 118 | .addComponent(users_conected, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))) 119 | .addContainerGap(28, Short.MAX_VALUE)) 120 | ); 121 | jPanel1Layout.setVerticalGroup( 122 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 123 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() 124 | .addContainerGap(47, Short.MAX_VALUE) 125 | .addComponent(users_conected) 126 | .addGap(27, 27, 27) 127 | .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 442, javax.swing.GroupLayout.PREFERRED_SIZE) 128 | .addGap(18, 18, 18) 129 | .addComponent(butPrivado, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE) 130 | .addGap(18, 18, 18) 131 | .addComponent(salir, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE) 132 | .addGap(24, 24, 24)) 133 | ); 134 | 135 | txtMensage.setBackground(new java.awt.Color(102, 102, 102)); 136 | txtMensage.setFont(new java.awt.Font("Poppins", 0, 14)); // NOI18N 137 | txtMensage.setForeground(new java.awt.Color(255, 255, 255)); 138 | txtMensage.setMargin(new java.awt.Insets(0, 20, 0, 0)); 139 | txtMensage.addActionListener(new java.awt.event.ActionListener() { 140 | public void actionPerformed(java.awt.event.ActionEvent evt) { 141 | txtMensageActionPerformed(evt); 142 | } 143 | }); 144 | 145 | butEnviar.setBackground(new java.awt.Color(52, 128, 101)); 146 | butEnviar.setFont(new java.awt.Font("Poppins", 1, 14)); // NOI18N 147 | butEnviar.setForeground(new java.awt.Color(255, 255, 255)); 148 | butEnviar.setText("Enviar"); 149 | butEnviar.addActionListener(new java.awt.event.ActionListener() { 150 | public void actionPerformed(java.awt.event.ActionEvent evt) { 151 | butEnviarActionPerformed(evt); 152 | } 153 | }); 154 | 155 | nombreGrandeUser.setFont(new java.awt.Font("Poppins", 0, 18)); // NOI18N 156 | nombreGrandeUser.setForeground(new java.awt.Color(255, 255, 255)); 157 | nombreGrandeUser.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); 158 | nombreGrandeUser.setText("Nombre"); 159 | 160 | panMostrar.setEditable(false); 161 | panMostrar.setBackground(new java.awt.Color(23, 25, 55)); 162 | panMostrar.setColumns(20); 163 | panMostrar.setFont(new java.awt.Font("Poppins", 0, 14)); // NOI18N 164 | panMostrar.setForeground(new java.awt.Color(255, 255, 255)); 165 | panMostrar.setRows(5); 166 | panMostrar.setCaretColor(new java.awt.Color(23, 25, 55)); 167 | panMostrar.setMargin(new java.awt.Insets(20, 20, 20, 20)); 168 | panMostrar.setMinimumSize(new java.awt.Dimension(21, 36)); 169 | jScrollPane1.setViewportView(panMostrar); 170 | 171 | javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); 172 | jPanel2.setLayout(jPanel2Layout); 173 | jPanel2Layout.setHorizontalGroup( 174 | jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 175 | .addGroup(jPanel2Layout.createSequentialGroup() 176 | .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 177 | .addGap(37, 37, 37) 178 | .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) 179 | .addGroup(jPanel2Layout.createSequentialGroup() 180 | .addComponent(txtMensage, javax.swing.GroupLayout.PREFERRED_SIZE, 604, javax.swing.GroupLayout.PREFERRED_SIZE) 181 | .addGap(18, 18, 18) 182 | .addComponent(butEnviar, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)) 183 | .addComponent(nombreGrandeUser, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 184 | .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING)) 185 | .addContainerGap(45, Short.MAX_VALUE)) 186 | ); 187 | jPanel2Layout.setVerticalGroup( 188 | jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 189 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 190 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() 191 | .addGap(42, 42, 42) 192 | .addComponent(nombreGrandeUser) 193 | .addGap(26, 26, 26) 194 | .addComponent(jScrollPane1) 195 | .addGap(18, 18, 18) 196 | .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) 197 | .addComponent(butEnviar, javax.swing.GroupLayout.DEFAULT_SIZE, 50, Short.MAX_VALUE) 198 | .addComponent(txtMensage)) 199 | .addGap(28, 28, 28)) 200 | ); 201 | 202 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 203 | getContentPane().setLayout(layout); 204 | layout.setHorizontalGroup( 205 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 206 | .addGroup(layout.createSequentialGroup() 207 | .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 208 | .addGap(0, 0, Short.MAX_VALUE)) 209 | ); 210 | layout.setVerticalGroup( 211 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 212 | .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 213 | ); 214 | 215 | pack(); 216 | setLocationRelativeTo(null); 217 | }// //GEN-END:initComponents 218 | 219 | Vector nomUsers; 220 | VentanaPrivada ventPrivada; 221 | Cliente cliente; 222 | public String user_name; 223 | 224 | private void butEnviarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butEnviarActionPerformed 225 | String mensaje = txtMensage.getText(); 226 | cliente.flujo(mensaje); 227 | txtMensage.setText(""); 228 | }//GEN-LAST:event_butEnviarActionPerformed 229 | 230 | private void txtMensageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtMensageActionPerformed 231 | String mensaje = txtMensage.getText(); 232 | cliente.flujo(mensaje); 233 | txtMensage.setText(""); 234 | }//GEN-LAST:event_txtMensageActionPerformed 235 | 236 | private void butPrivadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butPrivadoActionPerformed 237 | int pos = this.lstActivos.getSelectedIndex(); 238 | if (pos >= 0) { 239 | ventPrivada.setAmigo(nomUsers.get(pos)); 240 | ventPrivada.setVisible(true); 241 | } 242 | }//GEN-LAST:event_butPrivadoActionPerformed 243 | 244 | private void salirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_salirActionPerformed 245 | cliente.flujo("El cliente " + user_name + " se ha desconectado..."); 246 | System.exit(0); 247 | }//GEN-LAST:event_salirActionPerformed 248 | 249 | public void enviarMensaje(String mensaje) { 250 | cliente.flujo(mensaje); 251 | } 252 | 253 | public JTextField getTxtMensage() { 254 | return txtMensage; 255 | } 256 | 257 | public void setTxtMensage(JTextField txtMensage) { 258 | this.txtMensage = txtMensage; 259 | } 260 | 261 | public void actualizarChats(Vector datos) { 262 | nomUsers = datos; 263 | lstActivos.remove(0); 264 | ponerDatosList(this.lstActivos, nomUsers); 265 | } 266 | 267 | public void setNombreUser(String user) { 268 | nombreGrandeUser.setText("Chat general de " + user); 269 | } 270 | 271 | public void mostrarMsg(String msg) { 272 | this.panMostrar.append(msg + "\n\n\n"); 273 | } 274 | 275 | public void ponerActivos(Vector datos) { 276 | cambiarNumero(datos); 277 | nomUsers = datos; 278 | ponerDatosList(this.lstActivos, nomUsers); 279 | } 280 | 281 | public void cambiarNumero(Vector datos) { 282 | this.users_conected.setText("Hay " + datos.size() + " usuarios conectados"); 283 | } 284 | 285 | public void agregarUser(String user) { 286 | nomUsers.add(user); 287 | cambiarNumero(nomUsers); 288 | ponerDatosList(this.lstActivos, nomUsers); 289 | } 290 | 291 | public void retirraUser(String user) { 292 | nomUsers.remove(user); 293 | ponerDatosList(this.lstActivos, nomUsers); 294 | } 295 | 296 | private void ponerDatosList(JList list, final Vector datos) { 297 | list.setModel(new AbstractListModel() { 298 | @Override 299 | public int getSize() { 300 | return datos.size(); 301 | } 302 | 303 | @Override 304 | public Object getElementAt(int i) { 305 | return datos.get(i); 306 | } 307 | }); 308 | } 309 | 310 | // ACÁ HAY QUE ARREGLAR-------------- 311 | public void bloqueo(String user) { 312 | this.txtMensage.setEnabled(false); 313 | } 314 | //----------------------------- 315 | 316 | public void mensageAmigo(String amigo, String msg) { 317 | ventPrivada.setAmigo(amigo); 318 | ventPrivada.mostrarMsg(msg); 319 | ventPrivada.setVisible(true); 320 | } 321 | 322 | public void bloquear() { 323 | this.butEnviar.setEnabled(false); 324 | this.txtMensage.setEnabled(false); 325 | } 326 | 327 | public VentanaCliente(String user) throws IOException { 328 | 329 | initComponents(); 330 | this.setTitle("Ventana cliente - " + user); 331 | 332 | user_name = user; 333 | 334 | cliente = new Cliente(this); 335 | cliente.conexion(user); 336 | 337 | Vector prueba = new Vector(); 338 | prueba = cliente.pedirUsuarios(); 339 | 340 | int contador = 0; 341 | 342 | for (int i = 0; i < prueba.size(); i++) { 343 | if (prueba.get(i).equals(user)) { 344 | contador++; 345 | } 346 | } 347 | 348 | if (contador > 1) { 349 | JOptionPane.showMessageDialog(null, "El usuario ya esta conectado"); 350 | System.exit(0); 351 | } else { 352 | JOptionPane.showMessageDialog(null, "Bienvenid@ " + user); 353 | nomUsers = new Vector(); 354 | ponerActivos(cliente.pedirUsuarios()); 355 | ventPrivada = new VentanaPrivada(cliente); 356 | 357 | setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 358 | setVisible(true); 359 | } 360 | } 361 | 362 | 363 | // Variables declaration - do not modify//GEN-BEGIN:variables 364 | public javax.swing.JButton butEnviar; 365 | public javax.swing.JToggleButton butPrivado; 366 | private javax.swing.JPanel jPanel1; 367 | private javax.swing.JPanel jPanel2; 368 | private javax.swing.JScrollPane jScrollPane1; 369 | private javax.swing.JScrollPane jScrollPane2; 370 | public javax.swing.JList lstActivos; 371 | public javax.swing.JLabel nombreGrandeUser; 372 | public javax.swing.JTextArea panMostrar; 373 | public javax.swing.JButton salir; 374 | public javax.swing.JTextField txtMensage; 375 | private javax.swing.JLabel users_conected; 376 | // End of variables declaration//GEN-END:variables 377 | 378 | } 379 | -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Vista/VentanaPrivada.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | -------------------------------------------------------------------------------- /Proyecto Java - chat/src/Vista/VentanaPrivada.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license 3 | * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template 4 | */ 5 | package Vista; 6 | 7 | import Modelo.Cliente; 8 | import java.awt.event.ActionEvent; 9 | import java.awt.event.WindowEvent; 10 | import java.awt.event.WindowListener; 11 | 12 | /** 13 | * 14 | * @author Santiago Baron Zuleta, Mauricio Sanchez, Sebastian Yepes 15 | */ 16 | public class VentanaPrivada extends javax.swing.JFrame { 17 | 18 | /** 19 | * This method is called from within the constructor to initialize the form. 20 | * WARNING: Do NOT modify this code. The content of this method is always 21 | * regenerated by the Form Editor. 22 | */ 23 | @SuppressWarnings("unchecked") 24 | // //GEN-BEGIN:initComponents 25 | private void initComponents() { 26 | 27 | jPanel1 = new javax.swing.JPanel(); 28 | jScrollPane1 = new javax.swing.JScrollPane(); 29 | panMostrar = new javax.swing.JTextArea(); 30 | txtMensage = new javax.swing.JTextField(); 31 | butEnviar = new javax.swing.JButton(); 32 | jLabel1 = new javax.swing.JLabel(); 33 | 34 | setResizable(false); 35 | addWindowListener(new java.awt.event.WindowAdapter() { 36 | public void windowClosing(java.awt.event.WindowEvent evt) { 37 | formWindowClosing(evt); 38 | } 39 | }); 40 | 41 | jPanel1.setBackground(new java.awt.Color(18, 26, 47)); 42 | 43 | panMostrar.setEditable(false); 44 | panMostrar.setBackground(new java.awt.Color(23, 25, 55)); 45 | panMostrar.setColumns(18); 46 | panMostrar.setFont(new java.awt.Font("Poppins", 0, 14)); // NOI18N 47 | panMostrar.setForeground(new java.awt.Color(255, 255, 255)); 48 | panMostrar.setRows(5); 49 | panMostrar.setAutoscrolls(false); 50 | panMostrar.setMargin(new java.awt.Insets(20, 20, 20, 20)); 51 | jScrollPane1.setViewportView(panMostrar); 52 | 53 | txtMensage.setBackground(new java.awt.Color(102, 102, 102)); 54 | txtMensage.setFont(new java.awt.Font("Poppins", 0, 14)); // NOI18N 55 | txtMensage.setForeground(new java.awt.Color(255, 255, 255)); 56 | txtMensage.setMargin(new java.awt.Insets(0, 10, 0, 0)); 57 | 58 | butEnviar.setBackground(new java.awt.Color(52, 128, 101)); 59 | butEnviar.setFont(new java.awt.Font("Poppins", 1, 14)); // NOI18N 60 | butEnviar.setForeground(new java.awt.Color(255, 255, 255)); 61 | butEnviar.setText("Enviar"); 62 | butEnviar.addActionListener(new java.awt.event.ActionListener() { 63 | public void actionPerformed(java.awt.event.ActionEvent evt) { 64 | butEnviarActionPerformed(evt); 65 | } 66 | }); 67 | 68 | jLabel1.setFont(new java.awt.Font("Poppins", 0, 16)); // NOI18N 69 | jLabel1.setForeground(new java.awt.Color(255, 255, 255)); 70 | jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); 71 | jLabel1.setText("Chat con"); 72 | 73 | javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); 74 | jPanel1.setLayout(jPanel1Layout); 75 | jPanel1Layout.setHorizontalGroup( 76 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 77 | .addGroup(jPanel1Layout.createSequentialGroup() 78 | .addGap(27, 27, 27) 79 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) 80 | .addGroup(jPanel1Layout.createSequentialGroup() 81 | .addComponent(txtMensage, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE) 82 | .addGap(18, 18, 18) 83 | .addComponent(butEnviar, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)) 84 | .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 319, Short.MAX_VALUE) 85 | .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 86 | .addContainerGap(31, Short.MAX_VALUE)) 87 | ); 88 | jPanel1Layout.setVerticalGroup( 89 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 90 | .addGroup(jPanel1Layout.createSequentialGroup() 91 | .addGap(31, 31, 31) 92 | .addComponent(jLabel1) 93 | .addGap(18, 18, 18) 94 | .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 393, javax.swing.GroupLayout.PREFERRED_SIZE) 95 | .addGap(18, 18, 18) 96 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 97 | .addComponent(txtMensage, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE) 98 | .addComponent(butEnviar, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)) 99 | .addContainerGap(30, Short.MAX_VALUE)) 100 | ); 101 | 102 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 103 | getContentPane().setLayout(layout); 104 | layout.setHorizontalGroup( 105 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 106 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 107 | ); 108 | layout.setVerticalGroup( 109 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 110 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 111 | ); 112 | 113 | pack(); 114 | setLocationRelativeTo(null); 115 | }// //GEN-END:initComponents 116 | 117 | Cliente cliente; 118 | String amigo = ""; 119 | 120 | 121 | private void butEnviarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butEnviarActionPerformed 122 | String mensaje = txtMensage.getText(); 123 | mostrarMsg(cliente.getNombre() + ">" + mensaje); 124 | cliente.flujo(amigo, mensaje); 125 | txtMensage.setText(""); 126 | }//GEN-LAST:event_butEnviarActionPerformed 127 | 128 | private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing 129 | setVisible(false); 130 | }//GEN-LAST:event_formWindowClosing 131 | 132 | public void setAmigo(String ami) { 133 | this.amigo = ami; 134 | this.setTitle(ami); 135 | this.jLabel1.setText("Chat con " + ami); 136 | } 137 | 138 | public void mostrarMsg(String msg) { 139 | this.panMostrar.append(msg + "\n"); 140 | } 141 | 142 | public VentanaPrivada(Cliente clienteLlegada) { 143 | cliente = clienteLlegada; 144 | initComponents(); 145 | 146 | } 147 | 148 | 149 | // Variables declaration - do not modify//GEN-BEGIN:variables 150 | public javax.swing.JButton butEnviar; 151 | private javax.swing.JLabel jLabel1; 152 | private javax.swing.JPanel jPanel1; 153 | private javax.swing.JScrollPane jScrollPane1; 154 | private javax.swing.JTextArea panMostrar; 155 | private javax.swing.JTextField txtMensage; 156 | // End of variables declaration//GEN-END:variables 157 | } 158 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 📨 Java Chat 2 | 3 | Chat in Java with Sockets between a client and a server. 4 | 5 | ## Preview project 📸 6 | 7 | ![](https://i.imgur.com/Dqu2WU3.png) 8 | ![](https://i.imgur.com/cgWckyB.png) 9 | 10 | ## Installation 💻💡 11 | 12 | To install the project on your computer, you can use the "Code" button and follow the following steps in each case: 13 | 14 | ### 1️⃣ Clone the project 15 | 16 | - Copy the URL 17 | - Open your Git Bash 18 | - Write ``` git clone ``` and paste the url. As follows: 19 | 20 | ``` 21 | git clone https://github.com/santiagobaronz/Programation-advance.git 22 | ``` 23 | 24 | ### 2️⃣ Download ZIP 25 | 26 | - Click "Download ZIP" 27 | - Download the ZIP and extract the files into a folder 28 | - Open the folder in your favorite IDE (NetBeans is suggested) 29 | 30 | ``` 31 | 👉 Once downloaded, open "Control" folder and execute first "Servidor" and then "Cliente" 32 | ``` 33 | ## Authors 🦸‍♀️ 34 | 35 | - Santiago Baron Zuleta - *Project creator* [Santiago Baron Zuleta](https://github.com/santiagobaronz) --------------------------------------------------------------------------------