电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

通信软件设计实验报告VIP免费

通信软件设计实验报告_第1页
1/7
通信软件设计实验报告_第2页
2/7
通信软件设计实验报告_第3页
3/7
这个软件主要功能是以UDP为基础实现两台电脑之间收发简单文本消息。软件全部使用java编写,并以JavaBuilder8为工具进行编写与调试。布局方式采用NULL方式,主要使用AWT的组件和部分SWING的组件。使用方法如下:1首先在输入IP地址的输入栏中输入想与之进行通信的主机的IP地址,即消息接受方的IP地址。2在消息编辑框中输入想发送的消息内容。3编辑完欲发送的消息后,点击“发送消息”按钮进行发送;4双方发送的消息和发送方与接受方的IP地址都会在下面的空白区域----“频道”内显示。6如果没有输入IP地址便发送编辑完的文本消息,空白区域内会显示出提示信息提示用户应输入接受方的IP地址。7当频道内显示的消息太多时,可以按”刷新频道”来清除频道内全部信息!软件运行时候的抓图:本机测试结果的抓图效果程序代码与简要说明1chatFrame类的代码:packagechat;importjava.net.*;importjava.io.*;importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;/***

Title:

*

Description:

*

Copyright:Copyright(c)2004

*

Company:

*@authornotattributable*@version1.0*/publicclasschatFrameextendsJFrame{JPanelcontentPane;Labellabel1=newLabel();TextFieldtextField1=newTextField();Labellabel2=newLabel();TextFieldtextField2=newTextField();Buttonbutton1=newButton();TextAreatextArea1=newTextArea();DatagramPacketsendpacket,receivepacket;//定义发送和接受数据包DatagramSocketsendsocket,receivesocket;//定义发送和接受DatagramSocket//ConstructtheframepublicchatFrame(){enableEvents(AWTEvent.WINDOW_EVENT_MASK);try{jbInit();}catch(Exceptione){e.printStackTrace();}}//ComponentinitializationprivatevoidjbInit()throwsException{//定义个组件和他们的布局contentPane=(JPanel)this.getContentPane();label2.setAlignment(Label.CENTER);label2.setFont(newjava.awt.Font("SansSerif",0,15));label2.setForeground(Color.black);label2.setText("消息编辑框");label1.setBounds(newRectangle(14,17,133,32));contentPane.setLayout(null);this.setSize(newDimension(500,400));this.setTitle("用UDP实现聊天");textField1.setBackground(SystemColor.text);textField1.setColumns(0);textField1.setFont(newjava.awt.Font("Dialog",0,16));textField1.setText("");textField1.setBounds(newRectangle(129,72,200,61));label1.setAlignment(Label.CENTER);label1.setFont(newjava.awt.Font("Dialog",0,15));label1.setText("输入对方IP地址");label2.setBounds(newRectangle(23,86,108,28));try{sendsocket=newDatagramSocket(5000);//初始化receivesocket=newDatagramSocket(5001);}catch(SocketExceptionse){//可能产生Socketexception类的异常se.printStackTrace();System.exit(0);}button1.setBackground(Color.magenta);button1.setFont(newjava.awt.Font("Dialog",0,13));button1.setLabel("发送消息");button1.setBounds(newRectangle(374,23,88,42));button1.addActionListener(newjava.awt.event.ActionListener(){publicvoidactionPerformed(ActionEvente){button1_actionPerformed(e);}});textField2.setBackground(SystemColor.activeCaptionBorder);textField2.setFont(newjava.awt.Font("Dialog",1,18));textField2.setLocale(java.util.Locale.getDefault());textField2.setText("");textField2.setBounds(newRectangle(166,21,169,29));textArea1.setFont(newjava.awt.Font("Dialog",0,13));textArea1.setText("");textArea1.setBounds(newRectangle(46,157,382,185));contentPane.setBackground(newColor(113,111,159));jButton1.setBackground(Color.pink);jButton1.setBounds(newRectangle(374,86,87,42));jButton1.setFont(newjava.awt.Font("Dialog",0,13));jButton1.setText("刷新频道");jButton1.addActionListener(newjava.awt.event.ActionListener(){publicvoidactionPerformed(ActionEvente){jButton1_acti...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

通信软件设计实验报告

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部