Example usage for java.awt Container setCursor

List of usage examples for java.awt Container setCursor

Introduction

In this page you can find the example usage for java.awt Container setCursor.

Prototype

public void setCursor(Cursor cursor) 

Source Link

Document

Sets the cursor image to the specified cursor.

Usage

From source file:openlr.mapviewer.gui.MapViewerGui.java

/**
 * Sets the application cursor./*from   w ww  . ja  v  a2s  .c o  m*/
 * 
 * @param requester
 *            the requester
 * @param cursor
 *            the cursor
 */
public static void setApplicationCursor(final Container requester, final Cursor cursor) {
    Container current = requester;
    while (current.getParent() != null) {
        current = current.getParent();
    }
    current.setCursor(cursor);
}

From source file:org.photovault.swingui.ExportSelectedAction.java

@SuppressWarnings(value = "unchecked")
public void actionPerformed(ActionEvent ev) {
    File exportFile = null;/*  ww  w.j  av  a 2  s .  c  o  m*/
    if (view.getSelectedCount() > 1) {
        exportFile = new File("image_$n.jpg");
    } else {
        exportFile = new File("image.jpg");
    }
    ExportDlg dlg = new ExportDlg(null, true);
    dlg.setFilename(exportFile.getAbsolutePath());

    int retval = dlg.showDialog();
    if (retval == ExportDlg.EXPORT_OPTION) {
        Container c = view.getTopLevelAncestor();
        Cursor oldCursor = c.getCursor();
        c.setCursor(new Cursor(Cursor.WAIT_CURSOR));
        String exportFileTmpl = dlg.getFilename();
        int exportWidth = dlg.getImgWidth();
        int exportHeight = dlg.getImgHeight();
        Collection selection = view.getSelection();
        PhotoInfo[] exportPhotos = (PhotoInfo[]) selection.toArray(new PhotoInfo[selection.size()]);
        ExportProducer exporter = null;
        if (selection != null) {
            if (selection.size() > 1) {
                // Ensure that the numbering order is the same is in current view
                // TODO: sort the exported photos
                Comparator comp = view.ctrl.getPhotoComparator();
                if (comp != null) {
                    Arrays.sort(exportPhotos, comp);
                }
                String format = getSequenceFnameFormat(exportFileTmpl);
                BrowserWindow w = null;
                exporter = new ExportProducer(this, exportPhotos, format, exportWidth, exportHeight);
                setEnabled(false);
            } else {
                Iterator iter = selection.iterator();
                if (iter.hasNext()) {
                    PhotoInfo[] photos = new PhotoInfo[1];
                    photos[0] = (PhotoInfo) iter.next();
                    exporter = new ExportProducer(this, photos, exportFileTmpl, exportWidth, exportHeight);
                }
            }
            SwingWorkerTaskScheduler sched = (SwingWorkerTaskScheduler) Photovault.getInstance()
                    .getTaskScheduler();
            sched.registerTaskProducer(exporter, TaskPriority.EXPORT_IMAGE);
        }
        c.setCursor(oldCursor);
    }
}