xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

  • 大小: 51KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-06-03
  • 語言: 其他
  • 標簽: JAVA??GUI??TCP??Socket??

資源簡介

使用GUI和TCP網絡編程,實現圖形界面化客戶端給服務器發送消息,并附帶登陸注冊功能

資源截圖

代碼片段和文件信息

package?org.westos.Client;

import?java.awt.*;
import?java.awt.event.*;
import?java.io.DataOutputStream;
import?java.io.IOException;
import?java.io.OutputStream;
import?java.net.Socket;

public?class?Client{

????/**
?????*?客戶端
?????*/
????Socket?socket=null;

????public?Client()?{
????????/**
?????????*?一、創建窗體
?????????*/
????????//1.創建窗體
????????frame?frame?=?new?frame(“客戶端“);
????????//2.設置窗體布局
????????frame.setLayout(null);
????????frame.setBounds(200?200?500?400);
????????frame.setLocation(700300);
????????frame.setResizable(false);

????????//3.創建文本域、設置文本域背景色、設置文本域字體顏色
????????TextArea?textArea?=?new?TextArea();
????????textArea.setBounds(20?30??470?280);
????????textArea.setEditable(false);
????????textArea.setBackground(Color.DARK_GRAY);
????????textArea.setForeground(Color.white);
????????//4.創建文本框,用來輸入
????????TextField?textField?=?new?TextField();
????????textField.setBounds(20?320?470?30);
????????//4.創建發送、退出按鈕
????????Button?button?=?new?Button(“SEND“);
????????button.setBackground(Color.gray);
????????button.setBounds(340?360?50?30);

????????Button?button1?=?new?Button(“EXIT“);
????????button1.setBackground(Color.gray);
????????button1.setBounds(440?360?50?30);
????????//6.將文本域、文本框和按鈕加入到窗體里
????????frame.add(textArea);
????????frame.add(textField);
????????frame.add(button);
????????frame.add(button1);

????????//7.顯示窗體
????????frame.setVisible(true);
????????//8.給窗體添加關閉事件
????????frame.addWindowListener(new?WindowAdapter()?{
????????????@Override
????????????public?void?windowClosing(WindowEvent?e)?{
????????????????System.exit(0);
????????????}
????????});

????????//9.給退出按鈕添加事件
????????button1.addActionListener(new?ActionListener()?{
????????????@Override
????????????public?void?actionPerformed(ActionEvent?e)?{
????????????????System.exit(0);
????????????}
????????});

????????/**
?????????*?二、發送數據并顯示在文本域中
?????????*/
????????//1.與服務端建立連接,設置服務端ip和端口
????????try?{
????????????socket?=?new?Socket(“127.0.0.1“9999);
????????}?catch?(IOException?e)?{
????????????e.printStackTrace();
????????}
????????//2.在文本域textAree中提示一句話
????????textArea.append(“請輸入你要發送的數據:\r\n“);
????????//3.給發送按鈕添加事件,每點擊一次button按鈕(SEND)觸發一次
????????button.addActionListener(new?ActionListener()?{
????????????@Override
????????????public?void?actionPerformed(ActionEvent?e)?{
????????????????//3.1獲取文本狂textField中的數據
????????????????String?text?=?textField.getText();
????????????????//3.2將文本框textField中輸入的內容,添加到文本域textAree中
????????????????textArea.append(text+“\r\n“);
????????????????//3.3再將文本框置空
????????????????textField.setText(null);

????????????????//3.4獲取通道中的流
????????????????OutputStream?outputStream?=?null;
????????????????try?{
????????????????????outputStream?=?socket.getOutputStream();
????????????????}?catch?(IOException?e1)?{
????????????????????e1.printStackTrace();
????????????????}
????????????????//3.5包裝流
????????????????DataOutputStream

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-05-31?14:57??聊天室小項目\
?????目錄???????????0??2019-05-31?14:57??聊天室小項目\.idea\
?????目錄???????????0??2019-05-31?14:57??聊天室小項目\.idea\artifacts\
?????文件?????????312??2019-05-29?13:13??聊天室小項目\.idea\artifacts\Client_jar.xml
?????文件?????????312??2019-05-29?13:13??聊天室小項目\.idea\artifacts\Server_jar.xml
?????目錄???????????0??2019-05-31?14:57??聊天室小項目\.idea\dictionaries\
?????文件??????????87??2019-05-29?19:16??聊天室小項目\.idea\dictionaries\.xml
?????文件?????????258??2019-05-28?20:21??聊天室小項目\.idea\encodings.xml
?????文件?????????278??2019-05-28?19:58??聊天室小項目\.idea\misc.xml
?????文件?????????575??2019-05-30?13:20??聊天室小項目\.idea\modules.xml
?????文件???????18305??2019-05-30?16:14??聊天室小項目\.idea\workspace.xml
?????目錄???????????0??2019-05-31?14:57??聊天室小項目\out\
?????目錄???????????0??2019-05-31?14:57??聊天室小項目\out\artifacts\
?????目錄???????????0??2019-05-31?14:57??聊天室小項目\out\artifacts\Client_jar\
?????文件???????13026??2019-05-29?21:14??聊天室小項目\out\artifacts\Client_jar\客戶端Client.jar
?????目錄???????????0??2019-05-31?14:57??聊天室小項目\out\artifacts\Server_jar\
?????文件????????3221??2019-05-29?21:14??聊天室小項目\out\artifacts\Server_jar\服務端Server.jar
?????目錄???????????0??2019-05-31?14:57??聊天室小項目\out\production\
?????目錄???????????0??2019-05-31?14:57??聊天室小項目\out\production\客戶端Client\
?????目錄???????????0??2019-05-31?14:57??聊天室小項目\out\production\客戶端Client\meta-INF\
?????文件??????????65??2019-05-29?21:13??聊天室小項目\out\production\客戶端Client\meta-INF\MANIFEST.MF
?????目錄???????????0??2019-05-31?14:57??聊天室小項目\out\production\客戶端Client\org\
?????目錄???????????0??2019-05-31?14:57??聊天室小項目\out\production\客戶端Client\org\westos\
?????目錄???????????0??2019-05-31?14:57??聊天室小項目\out\production\客戶端Client\org\westos\Client\
?????文件?????????693??2019-05-29?19:47??聊天室小項目\out\production\客戶端Client\org\westos\Client\Client$1.class
?????文件?????????720??2019-05-29?19:47??聊天室小項目\out\production\客戶端Client\org\westos\Client\Client$2.class
?????文件????????1861??2019-05-29?19:47??聊天室小項目\out\production\客戶端Client\org\westos\Client\Client$3.class
?????文件????????2251??2019-05-29?19:47??聊天室小項目\out\production\客戶端Client\org\westos\Client\Client.class
?????文件?????????687??2019-05-30?16:06??聊天室小項目\out\production\客戶端Client\org\westos\Client\Login$1.class
?????文件????????2655??2019-05-30?16:06??聊天室小項目\out\production\客戶端Client\org\westos\Client\Login$2.class
?????文件?????????711??2019-05-30?16:06??聊天室小項目\out\production\客戶端Client\org\westos\Client\Login$3.class
............此處省略36個文件信息

評論

共有 條評論