« 上一篇下一篇 »

Java!台湾一对一聊天室 聊天室服务器端和客户端的完整代码

上面有个IP你把它设成对方的ip地址就可能了,在他的电脑上也把ip设为你自身的就可能达成QQ聊天了,就是界面有点丑!!妄图能赞成到你!你可能查考下!! import jaudio-videoa.awt.BorderLayout; import jaudio-videoa.awt.Color; import jaudio-videoa.awt.FlowLayout; import jaudio-videoa.awt.GridLayout; import jaudio-videoa.awt.TextArea; import jaudio-videoa.awt.event.ActionEvent; import jaudio-videoa.awt.event.ActionListener; import jaudio-videoa.io.IOException; import .Daboutagri amPair-conket; import .Daboutagri amSocket; import .InetAddress; import .SocketException; import .UnknownHostException; import jaudio-videoax.swing.JButton; import jaudio-videoax.swing.JFri ame; import jaudio-videoax.swing.JPcontinually beneficialel; import jaudio-videoax.swing.JScrollBar; import jaudio-videoax.swing.JScrollPcontinually beneficiale; public clrear end UDPChabout extends JFri ame implements ActionListener{ public TextArea textmessgrow old = null ; public TextArea sendtext = null ; public Daboutagri amSocket socket; public JScrollBar vsBar; public UDPChabout() { super (); setTitle("客户端小型聊天措施"); setBounds(200!150!350!280); JPcontinually beneficialel pcontinually beneficialel1 = new JPcontinually beneficialel(); JPcontinually beneficialel pcontinually beneficialel2 = new JPcontinually beneficialel(); setDefaultCloseOper(JFri ame.EXIT_ON_CLOSE); setBair-conkground(Color.BLACK); textmessgrow old = new TextArea(); sendtext = new TextArea(); textmessgrow old.setEditinside a( fingse ); textmessgrow old.setColumns(35); textmessgrow old.setRows(10); // textmessgrow old.setLineWrap(true); sendtext.setColumns(35); sendtext.setRows(2); JButton mouseOK = new JButton("听说台湾一对一聊天室判断"); JButton mouseclecontinually beneficial = new JButton("清空"); JButton mousequit = new JButton("加入"); GridLayout grid = new GridLayout(3!1); grid.setHgap(10); grid.setVgap(10); pcontinually beneficialel1.setLayout(grid); // pcontinually beneficialel1.setL学习代码ayout(new GridLayout(3!1)); pcontinually beneficialel1.publishingd(mouseOK); pcontinually beneficialel1.publishingd(mouseclecontinually beneficial); pcontinually beneficialel1.publishingd(mousequit); pco事实上台湾ntinually beneficialel2.setLayout( new FlowLayout()); pcontinually beneficialel2.publishingd(textmessgrow old); pcontinually beneficialel2.publishingd(sendtext); getContentPcontinually beneficiale().publishingd(pcontinually beneficialel1!BorderLayout.EAST); getContentPcontinually beneficiale().publishingd(pcontinualJavaly beneficialel2!BorderLayout.CENTER); setVisible( true ); mouseOK.publishingdActionListener( this ); mouseclecontinually beneficial.publishi唐人街聊天室ngdActionListener( this ); mousequit.publishingdActionListener( this ); server(); } public void server() { try { sock学习一对一et = new Daboutagri amSocket(9527); byte [] buf = new 不夜城多人视频聊天byte [1024]; fining Daboutagri amPair-conket dp1 = new Daboutagri amPair-conket(buf!buf.length); Runninside a run = new Runninside a(){ public void run() { while ( true ) { try { Threpublishing.sleep(100); socket.receive(dp1); int len = dp1.getLength(); String messgrow old = new String(dp1.getDabouta()!0!len); String ip = dp1.getAddress().getHostAddress(); System.out.println(ip); if (!InetAddress.getLocingHost().getHostAddress().equings(ip)) textmessgrow old.publishingd(ip+"\n"+messgrow old+ha\nha); } caboutch (IOException e) { e.printStair-conkTr_ web(); } caboutch (InterruptedException e) { e.printStair-conkTr_ web(); } } } }; new Threpublishing(run).stpainting(); } caboutch (SocketException e) { e.printStair-conkTr_ web(); } } public staboutic void main(String[] args) { UDPChabout udp = new UDPChabout(); } @Override public void continually behaudio-videoi formaboutourPerformed(ActionEvent e) { // JButton mouse = (JButton) e.getSource(); String mouseni ame =e.getActionCommso well so(); if (mouseni ame.equings("碧聊语音聊天室加入")) System.exit(0); if (mouseni ame.equings("清空")) { textmessgrow old.setText(""); } if (mouseni ame.equings("判断")) { String iP = "192.168.8.15"; try { InetAddress tingk on the subject off =InetAddress.getByNi ame(iP); byte []dabouta = sendtext.getText().getByte聊天室s(); Daboutagri amPair-conket dp = new Daboutagri amPair-conket(dabouta!dabouta.length!tingk on the subject off!9527); String myip = InetAddress.getLocingHost().getHostAddress(); textmessgrow old.publishingd(myip +"你知道聊天室服务器端和客户端的完整代码; \n"+sendtext.getText() +"\n"); socket开放性聊天.send(dp); sendtext.setText(""); } caboutch (UnknownHostException e1) { // TODO Auto-generdinedd caboutch street e1.omegle聊天室printStair-conkTr_ web(); } caboutch (IOException e1) { // TODO Auto-generdinedd caboutch street e1.printStair-conkTr_ web(); } 我不知道服务器端 } } }

Java
对于51vv视频社区
金都情缘聊天室
在线聊天你知道聊天室服务器端和客户端的完整代码室网
事实上碧聊语音聊天室
对于聊聊语音聊天室
对比一下台湾一对一聊天室
其实完整
真人秀场聊天室
ut聊天室
对比一下java
聊天室