Search in sources :

Example 1 with Cursor

use of java.awt.Cursor in project jna by java-native-access.

the class DragHandler method updateCursor.

/**
     * Hook to update the cursor on various {@link DragSourceEvent} updates.
     * @param ev event
     */
protected void updateCursor(DragSourceEvent ev) {
    if (!fixCursor)
        return;
    Cursor cursor = getCursorForAction(adjustDropAction(ev));
    ev.getDragSourceContext().setCursor(cursor);
}
Also used : Cursor(java.awt.Cursor)

Example 2 with Cursor

use of java.awt.Cursor in project jna by java-native-access.

the class DragHandler method dragGestureRecognized.

/** Called when a user drag gesture is recognized.  This method is 
     * responsible for initiating the drag operation.
     * @param e event
     */
public void dragGestureRecognized(DragGestureEvent e) {
    if ((e.getDragAction() & supportedActions) != 0 && canDrag(e)) {
        setModifiers(e.getTriggerEvent().getModifiersEx() & KEY_MASK);
        Transferable transferable = getTransferable(e);
        if (transferable == null)
            return;
        try {
            Point srcOffset = new Point(0, 0);
            Icon icon = getDragIcon(e, srcOffset);
            Point origin = e.getDragOrigin();
            // offset of the image origin from the cursor
            imageOffset = new Point(srcOffset.x - origin.x, srcOffset.y - origin.y);
            Icon dragIcon = scaleDragIcon(icon, imageOffset);
            Cursor cursor = null;
            if (dragIcon != null && DragSource.isDragImageSupported()) {
                GraphicsConfiguration gc = e.getComponent().getGraphicsConfiguration();
                e.startDrag(cursor, createDragImage(gc, dragIcon), imageOffset, transferable, this);
            } else {
                if (dragIcon != null) {
                    Point screen = dragSource.getLocationOnScreen();
                    screen.translate(origin.x, origin.y);
                    Point cursorOffset = new Point(-imageOffset.x, -imageOffset.y);
                    ghost = new GhostedDragImage(dragSource, dragIcon, getImageLocation(screen), cursorOffset);
                    ghost.setAlpha(ghostAlpha);
                }
                e.startDrag(cursor, transferable, this);
            }
            dragStarted(e);
            moved = false;
            e.getDragSource().addDragSourceMotionListener(this);
            DragHandler.transferable = transferable;
        } catch (InvalidDnDOperationException ex) {
            if (ghost != null) {
                ghost.dispose();
                ghost = null;
            }
        }
    }
}
Also used : InvalidDnDOperationException(java.awt.dnd.InvalidDnDOperationException) Transferable(java.awt.datatransfer.Transferable) Point(java.awt.Point) Icon(javax.swing.Icon) Cursor(java.awt.Cursor) GraphicsConfiguration(java.awt.GraphicsConfiguration)

Example 3 with Cursor

use of java.awt.Cursor in project voltdb by VoltDB.

the class Grid method mouseMove.

/**
     * Method declaration
     *
     *
     * @param e
     * @param x
     * @param y
     */
public boolean mouseMove(Event e, int x, int y) {
    if (y <= iRowHeight) {
        int xb = x;
        x += iX - iGridWidth;
        int i = iColCount - 1;
        for (; i >= 0; i--) {
            if (x > -7 && x < 7) {
                break;
            }
            x += iColWidth[i];
        }
        if (i >= 0) {
            if (!bDrag) {
                setCursor(new Cursor(Cursor.E_RESIZE_CURSOR));
                bDrag = true;
                iXDrag = xb - iColWidth[i];
                iColDrag = i;
            }
            return true;
        }
    }
    return mouseExit(e, x, y);
}
Also used : Cursor(java.awt.Cursor)

Example 4 with Cursor

use of java.awt.Cursor in project voltdb by VoltDB.

the class Grid method mouseExit.

/**
     * Method declaration
     *
     *
     * @param e
     * @param x
     * @param y
     */
public boolean mouseExit(Event e, int x, int y) {
    if (bDrag) {
        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        bDrag = false;
    }
    return true;
}
Also used : Cursor(java.awt.Cursor)

Example 5 with Cursor

use of java.awt.Cursor in project android by JetBrains.

the class DeclaredDependenciesTableView method setHoveredDependency.

private void setHoveredDependency(@Nullable PsModuleDependency dependency) {
    getListTableModel().setHoveredDependency(dependency);
    Cursor cursor = getDefaultCursor();
    if (dependency != null) {
        cursor = getPredefinedCursor(HAND_CURSOR);
    }
    setCursor(cursor);
    repaint();
}
Also used : Cursor(java.awt.Cursor)

Aggregations

Cursor (java.awt.Cursor)135 IOException (java.io.IOException)34 File (java.io.File)27 Point (java.awt.Point)19 MouseEvent (java.awt.event.MouseEvent)16 MouseAdapter (java.awt.event.MouseAdapter)13 Component (java.awt.Component)12 BufferedReader (java.io.BufferedReader)10 FileInputStream (java.io.FileInputStream)10 InputStreamReader (java.io.InputStreamReader)10 JLabel (javax.swing.JLabel)10 ArrayList (java.util.ArrayList)8 URISyntaxException (java.net.URISyntaxException)7 Color (java.awt.Color)6 Insets (java.awt.Insets)6 WalletCallException (com.vaklinov.zcashui.ZCashClientCaller.WalletCallException)5 Dimension (java.awt.Dimension)5 GridBagConstraints (java.awt.GridBagConstraints)5 Rectangle (java.awt.Rectangle)5 JPanel (javax.swing.JPanel)5