Sharkysoft home

lava.gui
Class DragFrame

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Frame
                          |
                          +--javax.swing.JFrame
                                |
                                +--lava.gui.DragFrame
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.io.Serializable, javax.swing.WindowConstants

public class DragFrame
extends javax.swing.JFrame

Supports drag and drop operations in a JFrame.

Details: DragFrame is an extended version of JFrame that provides easy-to-use graphical support for in-frame drag and drop operations.

Since:
1998.10.22
Version:
1998.12.05
See Also:
DragSprite, Serialized Form

Inner classes inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Inner classes inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Inner classes inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
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.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DragFrame()
          Initializes a new DragFrame.
 
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 frame.
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, processKeyEvent, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getCursorType, getFrames, getIconImage, getMenuBar, getState, getTitle, isResizable, remove, removeNotify, setCursor, setIconImage, setMenuBar, setResizable, setState, setTitle
 
Methods inherited from class java.awt.Window
addWindowListener, applyResourceBundle, applyResourceBundle, dispose, getFocusOwner, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getOwnedWindows, getOwner, getToolkit, getWarningString, hide, isShowing, pack, postEvent, processEvent, removeWindowListener, setCursor, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setFont, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseMotionEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

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 frame coordinates. If the frame 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

DragFrame

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

paint

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

Details: In addition to repainting the frame and all its children, paint also refreshes the drag sprite (on top of the frame and all its children) if a drag is in progress.

Overrides:
paint in class java.awt.Container
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. (This method will automatically translate the point.)

Dragging may be temporarily suspended by supplying a null value for e. When dragging is suspended, the dragged 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