java c s资料_JavaC/SmodeClientJava -电脑资料

作者:ludejun98 import java .applet.*; import java.awt.*; import java.awt.event.*; import java.io.*; import java .net .*; //public String str; class javaclient extends Panel implements ActionListener { TextField tf; LudCanvas cv; Button b;

作者:ludejun98

importjava.applet.*;

import java.awt.*;

import java.awt.event.*;

import java.io.*;

import java.net.*;

//public String str;

class javaclient extends Panel implements ActionListener

{

TextField tf;

LudCanvas cv;

Button b;

LudPanel(LudCanvas cv)

{

this.cv = cv;

tf = new TextField("ludejun",30);

add(tf);

b = new Button("退出");

b.addActionListener(this);

add(b);

b = new Button("发送");

b.addActionListener(this);

add(b);

}

public str actionPerformed(ActionEvent ev)

{

String str = ev.getActionCommand();

if( str.equals("退出") )

{

//tf.setText("This is my first button");

System.exit(0);

}

else

{

str = tf.getText();

tf.setText("开始检测发送......");

return str;

}

}

public static void main(String args[])

{

String data;

Socket Client;

DataInputStream InputS;

DataInputStream KeyS;

PrintStream OutputS;

Basic h = new Basic();

int i = 0;

try

{

Client = new Socket(args[0],600);

InputS = new

DataInputStream(Client.getInputStream());

utputS = new PrintStream(Client.getOutputStream());

KeyS = new DataInputStream(System.in);

}

catch(IOException e)

{

System.out.println("Cannot Connect with Server");

return;

}

try

{

while (i<5)

{

data = KeyS.readLine();

OutputS.println(data);

System.out.println("ECHO From Server:"+ InputS.readLine());

i++;

}

}

catch(IOException e)

{

System.out.println("IOException Happened");

}

try

{

System.out.println("Now will end this program");

Client.close();

}

catch(IOException e)

{

System.out.println("system cannot close socket");

}

}

}

//@@@@@@@@@@@@@@@@@@@@@@@222

class LudCanvas extends Canvas

{

public void paint(Graphics g)

{

Rectangle r = getBounds();

g.setColor(Color.red);

int panelHeight = 15;

int b = 3;

g.drawRect(b , b , r.width-b-b , r.height-b-b-panelHeight);

int t = 10;

g.drawRect(t , t , r.width-t-t , r.height-t-t-panelHeight);

g.drawString("The first applet of mine", 120, 30);

Image img = Toolkit.getDefaultToolkit().getImage("ie.gif");

g.drawImage(img, 50, 50, this);

}

}

class LudPanel extends Panel implements ActionListener

{

TextField tf;

LudCanvas cv;

Button b;

LudPanel(LudCanvas cv)

{

this.cv = cv;

tf = new TextField("ludejun",30);

add(tf);

b = new Button("退出");

b.addActionListener(this);

add(b);

b = new Button("发送");

b.addActionListener(this);

add(b);

}

public void actionPerformed(ActionEvent ev)

{

String str = ev.getActionCommand();

if( str.equals("退出") )

{

//tf.setText("This is my first button");

System.exit(0);

}

else

{

tf.setText("开始检测发送......");

}

}

}

:em51: :em51: :em51:

原文转自:http://www.ltesting.net

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值