JavaUDP聊天程序Java认证考试
文章作者 100test 发表时间 2010:03:13 17:32:52
来源 100Test.Com百考试题网
import java.awt.BorderLayout.
import java.awt.List.
import java.awt.TextField.
import java.awt.event.ActionEvent.
import java.awt.event.ActionListener.
import java.io.IOException.
import java.net.DatagramPacket.
import java.net.DatagramSocket.
import java.net.InetAddress.
import java.net.SocketException.
import java.net.UnknownHostException.
import javax.swing.JFrame.
import javax.swing.JPanel.
public class netchat {
JFrame jf=new JFrame("我的网络聊天程序").
List l=new List(6).
JPanel jp=new JPanel().
TextField tip=new TextField(15).
TextField tdata=new TextField(15).
DatagramSocket ds.
//DatagramPacket dp.
public netchat()
{
tip.setText("127.0.0.1").
try {
ds=new DatagramSocket(3000).
} catch (SocketException e) {
// TODO Auto-generated catch block
e.printStackTrace().
}
new Thread(new Runnable()
{
DatagramPacket dp.