Java datagram programming test program

Source: Internet
Author: User

This is written as a test program used in subsequent datagram programming. This program includes a set of custom events and a Java bean component that can display images in a scrolling manner.
In the object-oriented programming, Event Message is the basic method for communication between objects. In a graphical user interface program, GUI component objects generate various types of event messages based on user interaction. These event messages are captured by the event processing code of the application program, after corresponding processing, the message response object is driven to respond.
For this program, the requirement is as follows: when the data receiver receives the data, an event is generated and the event processor is activated. to this end, you need to customize related object classes. In java, defining User Event objects includes defining event listeners and defining event classes. The usage is the same as that of standard events.
The classes to be defined include DataSwapEvent and DataSwapListener. A package class DataSwapListenerAdapter is also implemented.
DataSwapEvent is an event class. The list of classes is as follows:
Package recmail. multiservice;
Import java. awt .*;
Import java.net. DatagramPacket;
Public class DataSwapEvent
Extends java. util. EventObject {
Object source;
String id;
Java. awt. Image image;
Private DatagramPacket dp;
Public DataSwapEvent (){
Super (null );
  }
Public DataSwapEvent (Object ob ){
Super (ob );
This. source = ob;
  }
Public String getId (){
Return id;
  }
Public void setId (String id ){
This. id = id;
  }
Public void setImage (Image img ){
This. image = img;
  }
Public Image getImage (){
Return image;
  }
Public writable rampacket getDatagram (){
Return dp;
  }
Public void setDatagram (DatagramPacket dp1 ){
Dp = dp1;
  }
}
DataSwapListener class, which is a listener interface class.
Package recmail. multiservice;
Public interface DataSwapListener extends java. util. EventListener {
Public void OnDataSendFinished (Object s, DataSwapEvent e );
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.