Sharkysoft home

lava.gui
Class DragPanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--lava.gui.DragPanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class DragPanel
extends javax.swing.JPanel

Provide graphical support for drag and drop operations in a JPanel.

Details: DragPanel is an extended version of JPanel that provides graphical support for drag and drop operation.

Since:
2000.01.25
See Also:
DragSprite, Serialized Form

Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected  java.awt.Point drag_origin
          Drag origin.
protected  java.awt.Point drag_position
          Current drag position.
protected  DragSprite sprite
          Icon being dragged.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DragPanel()
          Initializes a new DragPanel.
 
Method Summary
 void beginDrag(DragSprite sprite, java.awt.event.MouseEvent origin)
          Initiates a drag operation.
 void beginDrag(DragSprite sprite, java.awt.Point origin)
          Initiates a drag operation.
 void continueDrag(java.awt.event.MouseEvent e)
          Updates the drag sprite position.
 void continueDrag(java.awt.Point p)
          Updates the drag sprite position.
 void endDrag()
          Terminates the dragging operation.
 java.awt.Dimension getDragAmount()
          Computes drag offset.
 java.awt.Point getDragOrigin()
          Returns drag origin.
 java.awt.Point getDragPosition()
          Returns drag position.
 java.awt.Point getFramePoint(java.awt.event.MouseEvent e)
          Computes the frame coordinates of the given MouseEvent.
 boolean isDragging()
          Indicates whether drag is in progress.
 void paint(java.awt.Graphics g)
          Repaints the Panel.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sprite

protected DragSprite sprite
Icon being dragged.

Details: sprite is the icon being dragged, or is null if no drag operation is in progress.

Since:
1988.10.22

drag_origin

protected java.awt.Point drag_origin
Drag origin.

Details: drag_origin is the Point where the drag object originated from, in glass pane coordinates. If dragging is suspended, the drag sprite should be redrawn at this location.

This value is meaningless if no dragging is in progress.

Since:
1988.10.22

drag_position

protected java.awt.Point drag_position
Current drag position.

Details: drag_position is the current Point of dragging, in Panel coordinates. If the Panel repaints during a drag, this is where the drag sprite should be drawn.

This value is meaningless if no dragging is in progress.

Since:
1988.10.22
Constructor Detail

DragPanel

public DragPanel()
Initializes a new DragPanel.
Since:
1988.10.22
Method Detail

paint

public void paint(java.awt.Graphics g)
Repaints the Panel.

Details: In addition to repainting the Panel and all its children, paint also refreshes the drag sprite if a drag is in progress.

Overrides:
paint in class javax.swing.JComponent
Parameters:
g - the graphics context
Since:
1988.10.22

beginDrag

public void beginDrag(DragSprite sprite,
                      java.awt.event.MouseEvent origin)
Initiates a drag operation.

Details: Calling beginDrag initializes a new drag operation using the supplied parameters. These parameters include a DragSprite (sprite) and the first MouseEvent associated with the dragging.

Parameters:
sprite - the DragSprite (i.e., image to be dragged)
origin - the drag origin
Since:
1988.10.22

beginDrag

public void beginDrag(DragSprite sprite,
                      java.awt.Point origin)
Initiates a drag operation.

Details: Calling beginDrag initializes a new drag operation using the supplied parameters. These parameters include a DragSprite (sprite) and the origin of the drag.

Parameters:
sprite - the DragSprite (i.e., image to be dragged)
origin - the drag origin
Since:
1988.11.16

continueDrag

public void continueDrag(java.awt.event.MouseEvent e)
Updates the drag sprite position.

Details: continueDrag updates the position of the drag sprite, repainting the old and new sprite regions so that icon appears correctly in the new location. The supplied MouseEvent (e) may be in any coordinate system, such as the coordinate system of the component from which the dragging originated. (continueDrag automatically translates the point.)

Dragging may be temporarily suspended by supplying a null value for e. When dragging is suspended, the drag image snaps back to the drag origin. This behavior is useful for indicating illegal drag destinations.

Parameters:
e - the MouseEvent associated with the new sprite position
Since:
1988.10.22

continueDrag

public void continueDrag(java.awt.Point p)
Updates the drag sprite position.

Details: continueDrag updates the position of the drag sprite, repainting the old and new sprite regions so that icon appears correctly in the new location.

Dragging may be temporarily suspended by supplying a null value for p. When dragging is suspended, the drag image snaps back to the drag origin. This behavior is useful for indicating illegal drag destinations.

Parameters:
p - the new drag coordinate
Since:
1988.11.16

endDrag

public void endDrag()
Terminates the dragging operation.

Details: endDrag terminates the dragging procedure by erasing the drag sprite.

Since:
1988.10.22

isDragging

public boolean isDragging()
Indicates whether drag is in progress.

Details: isDragging returns true if a drag is in progress, false otherwise.

Returns:
true iff drag in progress

getDragOrigin

public java.awt.Point getDragOrigin()
Returns drag origin.

Details: getDragOrigin returns the point, in frame coordinates, where dragging last began.

Returns:
drag origin

getDragPosition

public java.awt.Point getDragPosition()
Returns drag position.

Details: getDragPosition returns the point, in frame coordinates, of the last drag position.

Returns:
drag position

getDragAmount

public java.awt.Dimension getDragAmount()
Computes drag offset.

Details: getDragAmount computes the x and y offsets of the current drag position from the drag origin and returns it as a Dimension object.

Returns:
drag offset

getFramePoint

public final java.awt.Point getFramePoint(java.awt.event.MouseEvent e)
Computes the frame coordinates of the given MouseEvent.
Parameters:
e - the MouseEvent
Returns:
the glass pane coordinates
Since:
1998.10.22

Sharkysoft home