91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 8KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-07
  • 語言: Java
  • 標簽: java、??

資源簡介

關于java socket的通信軟件 。

資源截圖

代碼片段和文件信息


import?java.awt.*;
import?java.awt.event.*;
import?java.io.*;
import?javax.swing.*;
import?java.net.*;

public?class?Client?implements?ActionListener
{
???//這里有兩個圖形界面,一個是連接的frame另一個和服務器通信的界面frame1????
????private??Jframe?frame;
????private??JLabel?adress;
????private??JLabel?port;
?????????????JTextField?adresstext;
?????????????JTextField?porttext;
?????????????JButton?connect;
????
????private?Jframe?frame1;
????private?JLabel?shuru;
????private?JPanel?panel1;
????private?JPanel?panel2;
????private?JLabel?jieshou;
????????????JButton?send;
????static?JTextArea?shurukuang;
????static?TextArea?jieshoukuang;
????
????//從服務端接受的數據流
????static?BufferedReader?br1;
????//從客戶端輸出的數據流
????static?PrintStream?ps;
????//從通信界面中的輸入框接受的數據流
????static?BufferedReader?br2;
????static?Socket?client;
????//將輸入框字符串轉換為字符串流所需的字符串的輸入流
????static?ByteArrayInputStream?stringInputStream?;
????
???public?Client()?{
???????//連接界面的實例化
????????frame=new?Jframe();
????????adress=new?JLabel(“IP?地址“);
????????port?=new?JLabel(“端口號“);
????????adresstext=new?JTextField(“127.0.0.1“10);
????????porttext=new?JTextField(“2000“10);
????????connect=new?JButton(“連接“);
????????????//連接界面的布局???????????
????????frame.setLayout(new?FlowLayout());
????????frame.add(adress);
????????frame.add(adresstext);
????????frame.add(port);???
????????frame.add(porttext);
????????frame.add(connect);
????????frame.setVisible(true);
????????frame.setSize(200150);???????????
????????connect.addActionListener(this);
??????????//通信界面的實例化
????????frame1=new?Jframe();
????????shuru=new?JLabel(“請輸入“);
??????????shurukuang=new?JTextArea(“請輸入????“540);??
????????????
??????????panel1=new?JPanel();
??????????panel1.add(shuru);
??????????panel1.add(shurukuang);
??????????panel1.setLayout(new?FlowLayout());
??????????
??????????send=new?JButton(“發送“);?
??????????panel2=new?JPanel();
??????????jieshou=new?JLabel(“已接受“);
??????????
?????????jieshoukuang=new?TextArea(860);?????
??????????jieshoukuang.setEditable(false);
??????????
??????????panel2.add(jieshou);
??????????panel2.add(jieshoukuang);
??????????panel2.setLayout(new?FlowLayout());????????
??????????frame1.setLayout(new?FlowLayout());
??????????????//通信界面都的布局
??????????frame1.add(BorderLayout.NORTHpanel1);
??????????frame1.add(send);
??????????frame1.add(BorderLayout.SOUTHpanel2);
?????????????//連接時通信界面是處于看不到的
??????????frame1.setVisible(false);
??????????frame1.setSize(500350);
??????????send.addActionListener(this);??
????????????}
?????????//兩個界面當中都有相應的按鈕時間,為相應的時間添加動作
??????public??void??actionPerformed(ActionEvent?e)?{
?????????if(e.getSource()==connect){????
??????????try?{
??????????????????//當觸發連接按鈕時,實例化一個客戶端
????????????????client=new?Socket(“127.0.0.1“2000);????
??????????????????//隱藏連接界面,顯示通信界面
????????????????frame.setVisible(false);
????????????????frame1.setVisible(true);
????????????????jieshoukuang.append(“已經連接上服務器!“+“\n“);????????????
??????

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????299??2015-01-03?10:59??java聊天程序\.classpath
?????文件?????????392??2015-01-03?10:58??java聊天程序\.project
?????目錄???????????0??2015-01-03?11:09??java聊天程序\.settings\
?????文件??????????64??2015-01-03?11:09??java聊天程序\.settings\org.eclipse.core.resources.prefs
?????文件?????????598??2015-01-03?10:59??java聊天程序\.settings\org.eclipse.jdt.core.prefs
?????目錄???????????0??2015-01-03?11:09??java聊天程序\bin\
?????文件????????4469??2015-01-03?11:09??java聊天程序\bin\Client.class
?????文件????????2253??2015-01-03?11:09??java聊天程序\bin\Server.class
?????目錄???????????0??2015-01-03?11:09??java聊天程序\src\
?????文件????????5372??2015-01-03?11:09??java聊天程序\src\Client.java
?????文件????????1736??2015-01-03?11:09??java聊天程序\src\Server.java

評論

共有 條評論