Cliente - Cliente que lee y muestra la informacin que le...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
// Cliente que lee y muestra la informaci n que le env a un Servidor. import*; import*; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Cliente extends JFrame { private JTextField campoIntroducir; private JTextArea areaPantalla; private ObjectOutputStream salida; private ObjectInputStream entrada; private String mensaje = ""; private String servidorChat; private Socket cliente; // inicializar servidorChat y configurar GUI public Cliente( String host ) { super( "Cliente" ); servidorChat = host; // establecer el servidor al que se va a conectar este cliente Container contenedor = getContentPane(); // crear campoIntroducir y registrar componente de escucha campoIntroducir = new JTextField(); campoIntroducir.setEditable( false ); campoIntroducir.addActionListener( new ActionListener() { // enviar mensaje al servidor public void actionPerformed( ActionEvent evento ) { enviarDatos( evento.getActionCommand() ); campoIntroducir.setText( "" ); } } ); contenedor.add( campoIntroducir, BorderLayout.NORTH ); // crear areaPantalla areaPantalla = new JTextArea(); contenedor.add( new JScrollPane( areaPantalla ), BorderLayout.CENTER ); setSize( 300, 150 ); setVisible( true ); } // fin del constructor de Cliente // conectarse al servidor y procesar mensajes del servidor private void ejecutarCliente() { // conectarse al servidor, obtener flujos, procesar la conexi n
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/04/2011 for the course ECOM 101 taught by Professor Juan during the Spring '11 term at Université de Caen Basse Normandie, Caen University.

Page1 / 4

Cliente - Cliente que lee y muestra la informacin que le...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online