Search in sources :

Example 11 with Cursor

use of java.awt.Cursor in project adempiere by adempiere.

the class PDFViewerBean method print.

public void print() {
    PrinterJob printJob = PrinterJob.getPrinterJob();
    //decoder.enableScaledPrinting(false);
    printJob.setPageable(decoder);
    final PageFormat pf = printJob.defaultPage();
    decoder.setPageFormat(pf);
    decoder.setTextPrint(PdfDecoder.TEXTGLYPHPRINT);
    printJob.setPrintable(decoder, pf);
    if (printJob.printDialog()) {
        final Cursor oldCursor = getCursor();
        try {
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            printJob.print();
        } catch (PrinterException e) {
            e.printStackTrace();
        } finally {
            setCursor(oldCursor);
        }
    }
}
Also used : PageFormat(java.awt.print.PageFormat) PrinterException(java.awt.print.PrinterException) Cursor(java.awt.Cursor) PrinterJob(java.awt.print.PrinterJob)

Example 12 with Cursor

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

the class XDragSourceContextPeer method startDrag.

protected void startDrag(Transferable transferable, long[] formats, Map formatMap) {
    Component component = getTrigger().getComponent();
    Component c = null;
    XWindowPeer wpeer = null;
    for (c = component; c != null && !(c instanceof Window); c = AWTAccessor.getComponentAccessor().getParent(c)) ;
    if (c instanceof Window) {
        wpeer = (XWindowPeer) c.getPeer();
    }
    if (wpeer == null) {
        throw new InvalidDnDOperationException("Cannot find top-level for the drag source component");
    }
    long xcursor = 0;
    long rootWindow = 0;
    long dragWindow = 0;
    long timeStamp = 0;
    /* Retrieve the X cursor for the drag operation. */
    {
        Cursor cursor = getCursor();
        if (cursor != null) {
            xcursor = XGlobalCursorManager.getCursor(cursor);
        }
    }
    XToolkit.awtLock();
    try {
        if (proxyModeSourceWindow != 0) {
            throw new InvalidDnDOperationException("Proxy drag in progress");
        }
        if (dndInProgress) {
            throw new InvalidDnDOperationException("Drag in progress");
        }
        /* Determine the root window for the drag operation. */
        {
            long screen = XlibWrapper.XScreenNumberOfScreen(wpeer.getScreen());
            rootWindow = XlibWrapper.RootWindow(XToolkit.getDisplay(), screen);
        }
        dragWindow = XWindow.getXAWTRootWindow().getWindow();
        timeStamp = XToolkit.getCurrentServerTime();
        int dropActions = getDragSourceContext().getSourceActions();
        Iterator dragProtocols = XDragAndDropProtocols.getDragSourceProtocols();
        while (dragProtocols.hasNext()) {
            XDragSourceProtocol dragProtocol = (XDragSourceProtocol) dragProtocols.next();
            try {
                dragProtocol.initializeDrag(dropActions, transferable, formatMap, formats);
            } catch (XException xe) {
                throw (InvalidDnDOperationException) new InvalidDnDOperationException().initCause(xe);
            }
        }
        /* Install X grabs. */
        {
            int status;
            XWindowAttributes wattr = new XWindowAttributes();
            try {
                status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(), rootWindow, wattr.pData);
                if (status == 0) {
                    throw new InvalidDnDOperationException("XGetWindowAttributes failed");
                }
                rootEventMask = wattr.get_your_event_mask();
                XlibWrapper.XSelectInput(XToolkit.getDisplay(), rootWindow, rootEventMask | ROOT_EVENT_MASK);
            } finally {
                wattr.dispose();
            }
            XBaseWindow.ungrabInput();
            status = XlibWrapper.XGrabPointer(XToolkit.getDisplay(), rootWindow, 0, GRAB_EVENT_MASK, XConstants.GrabModeAsync, XConstants.GrabModeAsync, XConstants.None, xcursor, timeStamp);
            if (status != XConstants.GrabSuccess) {
                cleanup(timeStamp);
                throwGrabFailureException("Cannot grab pointer", status);
                return;
            }
            status = XlibWrapper.XGrabKeyboard(XToolkit.getDisplay(), rootWindow, 0, XConstants.GrabModeAsync, XConstants.GrabModeAsync, timeStamp);
            if (status != XConstants.GrabSuccess) {
                cleanup(timeStamp);
                throwGrabFailureException("Cannot grab keyboard", status);
                return;
            }
        }
        /* Update the global state. */
        dndInProgress = true;
        dragInProgress = true;
        dragRootWindow = rootWindow;
        sourceActions = dropActions;
        sourceFormats = formats;
    } finally {
        XToolkit.awtUnlock();
    }
    /* This implementation doesn't use native context */
    setNativeContext(0);
    SunDropTargetContextPeer.setCurrentJVMLocalSourceTransferable(transferable);
}
Also used : Window(java.awt.Window) InvalidDnDOperationException(java.awt.dnd.InvalidDnDOperationException) Component(java.awt.Component) Cursor(java.awt.Cursor)

Example 13 with Cursor

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

the class DragSourceContext method updateCurrentCursor.

/**
     * If the default drag cursor behavior is active, this method
     * sets the default drag cursor for the specified actions
     * supported by the drag source, the drop target action,
     * and status, otherwise this method does nothing.
     *
     * @param sourceAct the actions supported by the drag source
     * @param targetAct the drop target action
     * @param status one of the fields <code>DEFAULT</code>,
     *               <code>ENTER</code>, <code>OVER</code>,
     *               <code>CHANGED</code>
     */
protected synchronized void updateCurrentCursor(int sourceAct, int targetAct, int status) {
    if (useCustomCursor) {
        return;
    }
    // do defaults processing
    Cursor c = null;
    switch(status) {
        default:
            targetAct = DnDConstants.ACTION_NONE;
        case ENTER:
        case OVER:
        case CHANGED:
            int ra = sourceAct & targetAct;
            if (ra == DnDConstants.ACTION_NONE) {
                // no drop possible
                if ((sourceAct & DnDConstants.ACTION_LINK) == DnDConstants.ACTION_LINK)
                    c = DragSource.DefaultLinkNoDrop;
                else if ((sourceAct & DnDConstants.ACTION_MOVE) == DnDConstants.ACTION_MOVE)
                    c = DragSource.DefaultMoveNoDrop;
                else
                    c = DragSource.DefaultCopyNoDrop;
            } else {
                // drop possible
                if ((ra & DnDConstants.ACTION_LINK) == DnDConstants.ACTION_LINK)
                    c = DragSource.DefaultLinkDrop;
                else if ((ra & DnDConstants.ACTION_MOVE) == DnDConstants.ACTION_MOVE)
                    c = DragSource.DefaultMoveDrop;
                else
                    c = DragSource.DefaultCopyDrop;
            }
    }
    setCursorImpl(c);
}
Also used : Cursor(java.awt.Cursor) Point(java.awt.Point)

Example 14 with Cursor

use of java.awt.Cursor in project jabref by JabRef.

the class HelpAction method getHelpLabel.

public JLabel getHelpLabel(String labelText) {
    JLabel helpLabel = new JLabel("<html><u>" + labelText + "</u></html>");
    helpLabel.setForeground(Color.BLUE);
    helpLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
    helpLabel.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            openHelpPage();
        }
    });
    return helpLabel;
}
Also used : MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) Cursor(java.awt.Cursor)

Example 15 with Cursor

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

the class LWCursorManager method updateCursorImpl.

private void updateCursorImpl() {
    final Point cursorPos = getCursorPosition();
    final Component c = findComponent(cursorPos);
    final Cursor cursor;
    final Object peer = LWToolkit.targetToPeer(c);
    if (peer instanceof LWComponentPeer) {
        final LWComponentPeer<?, ?> lwpeer = (LWComponentPeer<?, ?>) peer;
        final Point p = lwpeer.getLocationOnScreen();
        cursor = lwpeer.getCursor(new Point(cursorPos.x - p.x, cursorPos.y - p.y));
    } else {
        cursor = (c != null) ? c.getCursor() : null;
    }
    setCursor(cursor);
}
Also used : Point(java.awt.Point) Component(java.awt.Component) Cursor(java.awt.Cursor)

Aggregations

Cursor (java.awt.Cursor)44 Point (java.awt.Point)9 Component (java.awt.Component)6 MouseEvent (java.awt.event.MouseEvent)5 File (java.io.File)5 JFrame (javax.swing.JFrame)5 BorderLayout (java.awt.BorderLayout)4 JPanel (javax.swing.JPanel)4 Dimension (java.awt.Dimension)3 IOException (java.io.IOException)3 JFileChooser (javax.swing.JFileChooser)3 JLabel (javax.swing.JLabel)3 ParameterBundle (gov.sandia.n2a.parms.ParameterBundle)2 Color (java.awt.Color)2 GridBagConstraints (java.awt.GridBagConstraints)2 GridBagLayout (java.awt.GridBagLayout)2 Insets (java.awt.Insets)2 StringSelection (java.awt.datatransfer.StringSelection)2 InvalidDnDOperationException (java.awt.dnd.InvalidDnDOperationException)2 MouseAdapter (java.awt.event.MouseAdapter)2