that is a String type of data and i know that BufferedReader.readLine()
returns String. My code is below:
package ChatVisual2Client;
import System.Drawing.*;
import System.Collections.*;
import System.ComponentModel.*;
import System.Windows.Forms.*;
import System.Data.*;
import java.io.*;
import java.net.*;
/**
* Summary description for Form1.
*/
public class Form1 extends System.Windows.Forms.Form
{
private System.Windows.Forms.GroupBox groupBox1;
private static System.Windows.Forms.TextBox txtMessage;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Label label1;
private static System.Windows.Forms.TextBox txtConnection;
/**
* Required designer variable.
*/
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
try
{
Socket client=new Socket("192.168.0.139",15);
txtConnection.set_Text("Kuruldu!");
BufferedReader reader=new BufferedReader(new
InputStreamReader(client.getInputStream()));
String alinanMesaj=reader.readLine();
if(alinanMesaj!=null)
{
txtMessage.set_Text(reader.readLine());
}
}
catch (IOException ioe)
{
System.err.println ("Error " + ioe);
}
}
protected void Dispose(boolean disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
super.Dispose(disposing);
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.txtMessage = new System.Windows.Forms.TextBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.txtConnection = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.set_Location(new System.Drawing.Point(16, 64));
this.groupBox1.set_Name("groupBox1");
this.groupBox1.set_Size(new System.Drawing.Size(312, 200));
this.groupBox1.set_TabIndex(3);
this.groupBox1.set_TabStop(false);
this.groupBox1.set_Text("Mesaj");
//
// txtMessage
//
this.txtMessage.set_Location(new System.Drawing.Point(24, 88));
this.txtMessage.set_Multiline(true);
this.txtMessage.set_Name("txtMessage");
this.txtMessage.set_Size(new System.Drawing.Size(296, 168));
this.txtMessage.set_TabIndex(4);
this.txtMessage.set_Text("");
//
// groupBox2
//
this.groupBox2.get_Controls().Add(this.label1);
this.groupBox2.get_Controls().Add(this.txtConnecti on);
this.groupBox2.set_Location(new System.Drawing.Point(16, 8));
this.groupBox2.set_Name("groupBox2");
this.groupBox2.set_Size(new System.Drawing.Size(184, 48));
this.groupBox2.set_TabIndex(5);
this.groupBox2.set_TabStop(false);
this.groupBox2.set_Text("Baglanti");
//
// txtConnection
//
this.txtConnection.set_Location(new System.Drawing.Point(72, 16));
this.txtConnection.set_Name("txtConnection");
this.txtConnection.set_TabIndex(3);
this.txtConnection.set_Text("");
//
// label1
//
this.label1.set_Font(new System.Drawing.Font("Microsoft Sans Serif",
8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((ubyte)(System.Byte)(((ubyte)162)))));
this.label1.set_Location(new System.Drawing.Point(16, 19));
this.label1.set_Name("label1");
this.label1.set_Size(new System.Drawing.Size(56, 16));
this.label1.set_TabIndex(4);
this.label1.set_Text("Durum :");
//
// Form1
//
this.set_AutoScaleBaseSize(new System.Drawing.Size(5, 13));
this.set_ClientSize(new System.Drawing.Size(336, 278));
this.get_Controls().Add(this.groupBox2);
this.get_Controls().Add(this.txtMessage);
this.get_Controls().Add(this.groupBox1);
this.set_Name("Form1");
this.set_Text("Sohbet Programı - Client");
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
public static void main(String[] args)
{
Application.Run(new Form1());
}
}
"Lars-Inge Tønnessen [VJ# MVP]" wrote:
Quote:
Hi Asilter
Please show us more code. I can read code better than text.
What is "alinanMesaj" ?
Maybe this is a textfield you forget to make a new instance of and assigning
the value to the alinanMesaj.Text filed ? I'm only guessing because I don't
know what "alinanMesaj" is from your very short code sample.
reader=new BufferedReader(new InputStreamReader(client.getInputStream()));
alinanMesaj=reader.readLine();
Best regards,
Lars-Inge Tønnessen |