Example usage for java.awt Container getCursor

List of usage examples for java.awt Container getCursor

Introduction

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

Prototype

public Cursor getCursor() 

Source Link

Document

Gets the cursor set in the component.

Usage

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

/**
 * Gets the application cursor./* www.j ava 2 s. c  o m*/
 * 
 * @param requester
 *            the requester
 * @return the application cursor
 */
public static Cursor getApplicationCursor(final Container requester) {
    Container current = requester;
    while (current.getParent() != null) {
        current = current.getParent();
    }
    return current.getCursor();
}

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

@SuppressWarnings(value = "unchecked")
public void actionPerformed(ActionEvent ev) {
    File exportFile = null;/*ww w .j  a v a 2 s .  com*/
    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);
    }
}