Next: Binding Properties
Up: How Are the Existing
Previous: Adding a Bean
Moving a bean from one position to another inside the BeanBox is done by moving the wrapper object, which wraps that bean. When the mouse is clicked on the edge of the wrapper, the mouse pointer changes its image from an arrow pointer to a moving pointer, and the moving process begins. Every wrapper is a MouseListener of its encapsulated component, and responds to any MouseEvent. On a receipt of a MouseEvent, the wrapper responds by performing some work locally, and then propagating that event to the BeanBox. In this case, the wrapper calls the startMove() method of BeanBox, which will consequently change the arrow pointer to a moving pointer, and record which wrapper is in the process of moving. While dragging the bean with the mouse to the desired destination, the wrapper does nothing locally, but BeanBox will at every new position draw a red line box, which represents where the bean will be positioned if the mouse is released at that point. Finally, when mouse is released, the BeanBox erases the red line box and sets the new location of the wrapper (and consequently the bean inside it) to the coordinates where mouse was released.
Next: Binding Properties
Up: How Are the Existing
Previous: Adding a Bean