Gwt-ext experience Journey, Part 4: Experience dragging and communication

Source: Internet
Author: User
Tags client

Introduction: Gwt-ext is a powerful Web development control library based on Google Web Toolkit (GWT) and ExtJs. It is ideal for fast development of rich Internet applications in the pure Java language. This series of articles will detail the basic structure and features of Gwt-ext, and demonstrate the implementation of the technology through code examples. This article is the last part of the series that will experience the drag-and-drop effect of two commonly used drag-and-drop methods and some empirical summaries. In the introduction to communications, this article will also provide a detailed description of both synchronous and asynchronous communications.

Drag

It is simple to implement drag-and-drop function in Gwt-ext. Gwt-ext provides a drag-and-drop class in the COM.GWTEXT.CLIENT.DD package. Figure 1 shows the relationship of these classes.

Figure 1. Diagram of the class associated with the drag in the COM.GWTEXT.CLIENT.DD package

Where DragDrop is a base class that defines the interfaces and basic operations of elements that can be dragged, such as StartDrag, Ondrag, OnDragOver, and Ondragout events. and inherits from this class the subclass, the function mainly divides into two kinds. One is to allow the object to be dragged, one to make the drag object can be placed in the droptarget.

First, describe some classes that can help the object be dragged.

DD class

The user can make the object can be dragged by calling the DD constructor. This drag causes the object to move with the mouse moving.

DD DD = new DD (Component Component);//Parameter Component is the object being dragged

Ddproxy class

The Ddproxy class inherits from the DD class. When you use this class to construct a dragged object, the bounding rectangle of the object moves as the mouse moves. When the mouse is released, the object is dropped back to where the mouse stopped.

DD DD = new Ddproxy (Component Component);//Parameter Component is the object being dragged

Here, give an example of dragging a Panel. First, define a Panel,

Panel draggable = new Panel();
draggable.setTitle("Draggable");
draggable.setBorder(true);

This Panel is then used as a parameter to construct a DD class,

DD DD = new DD (draggable);

This way, the Panel can be dragged.

Figure 2. Panel where the object moves with the mouse

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.