Example usage for java.awt Component setCursor

List of usage examples for java.awt Component setCursor

Introduction

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

Prototype

public void setCursor(Cursor cursor) 

Source Link

Document

Sets the cursor image to the specified cursor.

Usage

From source file:gmgen.util.MiscUtilities.java

/**
 *  Set the cursor the the specified component to the specified cursor
 *
 *@param  component  The component to set the cursor for
 *@param  cursor  The cursor to set/* www  .  ja  v a 2 s.  c o m*/
 */
public static void setCursor(java.awt.Component component, Cursor cursor) {
    component.setCursor(cursor);
}

From source file:gmgen.util.MiscUtilities.java

/**
 *  Set the cursor for the specified component to the wait cursor
 *
 *@param  component  The component to set the cursor for
 *@return        The currently set cursor
 *///from   w w w  .  ja  va2  s .c o  m
public static Cursor setBusyCursor(java.awt.Component component) {
    Cursor old = component.getCursor();
    component.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

    return old;
}

From source file:storybook.toolkit.swing.SwingUtil.java

public static void setWaitingCursor(Component comp) {
    comp.setCursor(new Cursor(Cursor.WAIT_CURSOR));
}

From source file:org.broad.igv.ui.panel.PanTool.java

public void mouseReleased(final MouseEvent e) {

    if (isDragging) {
        isDragging = false;//from  w ww .j av a  2 s  .c  o  m
        lastDragEventTime = 0;
        getReferenceFame().dragStopped();
    }
    Component panel = (Component) e.getSource();
    panel.setCursor(getCursor());
}

From source file:org.broad.igv.ui.panel.PanTool.java

@Override
final public void mouseDragged(final MouseEvent e) {

    long currentTime = System.currentTimeMillis();

    if ((currentTime - lastDragEventTime) < throttleTimeMS) {
        return;/* w w w.jav  a2 s.c  om*/
    }

    //System.out.println("T=" + ctr);
    lastDragEventTime = currentTime;

    try {
        Component panel = (Component) e.getSource();
        panel.setCursor(dragCursor);
        if (lastMousePoint == null) {
            lastMousePoint = e.getPoint();
            return;
        }

        if (!isDragging && e.getPoint().distance(lastMousePoint) < 2) {
            return;
        } else {
            isDragging = true;

            int deltaX = lastMousePoint.x - e.getX();
            int deltaY = lastMousePoint.y - e.getY();
            cumulativeDeltaX += Math.abs(deltaX);
            cumulativeDeltaY += Math.abs(deltaY);

            // Test for horizontal vs vertical panning.
            if (cumulativeDeltaX > cumulativeDeltaY) {

                // Horizontal scrolling
                getReferenceFame().shiftOriginPixels(deltaX);
            } else {
                // Vertical Scrolling 
                int totalYChange = (int) (lastMousePoint.getY() - e.getY());
                if (totalYChange != 0) {

                    // This section handles false drag direction changes
                    int currentYDirection = 0;

                    // Figure out the current drag direction
                    currentYDirection = totalYChange / Math.abs(totalYChange);

                    // If the previous direction is 0 we were not moving before
                    if (previousYDirection != 0) {

                        // See if we changed direction
                        boolean changedYDirection = currentYDirection != previousYDirection;
                        if (!changedYDirection) {

                            // Don't save lastMousePressedPoint because may
                            // be incorrect (this is the problem we are
                            // solving with the direction flag) instead
                            // we'll just check the next drag Point to be
                            // sure of the correct direction.
                            previousYDirection = currentYDirection;

                            // If we have a vertical scrollbar use it to move
                            if (verticalScrollBar != null) {
                                int adjustedScrollbarValue = verticalScrollBar.getValue();
                                adjustedScrollbarValue += totalYChange;
                                verticalScrollBar.setValue(adjustedScrollbarValue);
                            }
                        }
                    }
                    previousYDirection = currentYDirection;

                }
            }
        }
    } finally {
        lastMousePoint = e.getPoint(); // Always save the last Point
    }
}

From source file:org.pentaho.reporting.designer.extensions.pentaho.repository.actions.PublishToServerTask.java

public void run() {
    final MasterReport report = reportDesignerContext.getActiveContext().getContextRoot();
    final DocumentMetaData metaData = report.getBundle().getMetaData();

    try {//from   w w  w .  ja v  a 2s  .  com
        final String oldName = extractLastFileName(report);

        SelectFileForPublishTask selectFileForPublishTask = new SelectFileForPublishTask(uiContext);
        readBundleMetaData(report, metaData, selectFileForPublishTask);

        final String selectedReport = selectFileForPublishTask.selectFile(loginData, oldName);
        if (selectedReport == null) {
            return;
        }

        loginData.setOption("lastFilename", selectedReport);
        storeBundleMetaData(report, selectedReport, selectFileForPublishTask);

        reportDesignerContext.getActiveContext().getAuthenticationStore().add(loginData, storeUpdates);

        final byte[] data = PublishUtil.createBundleData(report);
        int responseCode = PublishUtil.publish(data, selectedReport, loginData);

        if (responseCode == 200) {
            final Component glassPane = SwingUtilities.getRootPane(uiContext).getGlassPane();
            try {
                glassPane.setVisible(true);
                glassPane.setCursor(new Cursor(Cursor.WAIT_CURSOR));

                FileObject fileSystemRoot = PublishUtil.createVFSConnection(loginData);
                final JCRSolutionFileSystem fileSystem = (JCRSolutionFileSystem) fileSystemRoot.getFileSystem();
                fileSystem.getLocalFileModel().refresh();
            } catch (Exception e1) {
                UncaughtExceptionsModel.getInstance().addException(e1);
            } finally {
                glassPane.setVisible(false);
                glassPane.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
            }
            if (JOptionPane.showConfirmDialog(uiContext,
                    Messages.getInstance().getString("PublishToServerAction.Successful.LaunchNow"),
                    Messages.getInstance().getString("PublishToServerAction.Successful.LaunchTitle"),
                    JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                PublishUtil.launchReportOnServer(loginData.getUrl(), selectedReport);
            }
        } else if (responseCode == 403) {
            logger.error("Publish failed. Server responded with status-code " + responseCode);
            JOptionPane.showMessageDialog(uiContext,
                    Messages.getInstance().getString("PublishToServerAction.FailedAccess"),
                    Messages.getInstance().getString("PublishToServerAction.FailedAccessTitle"),
                    JOptionPane.ERROR_MESSAGE);
        } else {
            logger.error("Publish failed. Server responded with status-code " + responseCode);
            showErrorMessage();
        }
    } catch (Exception exception) {
        logger.error("Publish failed. Unexpected error:", exception);
        showErrorMessage();
    }
}

From source file:gda.gui.text.parameter.EpicsPanelParameterListener.java

@Override
public void vetoableChange(final PropertyChangeEvent e) throws PropertyVetoException {
    if (putTimeOut != null) {
        java.awt.Component c = null;
        Object obj = e.getSource();
        if (obj instanceof ParametersPanelBuilder.ParameterChangeEventSource) {
            Object field = ((ParametersPanelBuilder.ParameterChangeEventSource) obj).parameterField.field;
            if (field instanceof java.awt.Component) {
                c = (java.awt.Component) field;
            }//from  w  ww .j a  va2s  . c o m
        }
        if (c != null)
            c.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
        vetoableChangeinNewThread(e);
        if (c != null)
            c.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
    } else {
        Thread t = uk.ac.gda.util.ThreadManager.getThread(new Runnable() {
            @Override
            public void run() {
                try {
                    vetoableChangeinNewThread(e);
                } catch (Exception ex) {
                    exceptionUtils.logException(logger, "vetoableChange", ex);
                }
            }
        });
        t.setPriority(java.lang.Thread.MIN_PRIORITY);
        t.start();
    }
}

From source file:org.broad.igv.hic.MainWindow.java

public Component showGlassPane() {
    final Component glassPane = getGlassPane();
    glassPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    glassPane.setVisible(true);//from   w w  w.  j  av a  2 s  .c o  m
    return glassPane;
}

From source file:plugin.notes.gui.NotesView.java

/**
 *  {@literal handle File->Open.} Will open any .gmn files, and import them into your
 *  notes structure//from   w  w w  .j a va  2s . com
 */
public void handleOpen() {
    // TODO fix
    String sFile = SettingsHandler.getGMGenOption(OPTION_NAME_LASTFILE, System.getProperty("user.dir"));
    File defaultFile = new File(sFile);
    JFileChooser chooser = new JFileChooser();
    chooser.setCurrentDirectory(defaultFile);
    chooser.addChoosableFileFilter(getFileType());
    chooser.setFileFilter(getFileType());
    chooser.setMultiSelectionEnabled(true);
    Component component = GMGenSystem.inst;
    Cursor originalCursor = component.getCursor();
    component.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

    int option = chooser.showOpenDialog(GMGenSystem.inst);

    if (option == JFileChooser.APPROVE_OPTION) {
        for (File noteFile : chooser.getSelectedFiles()) {
            SettingsHandler.setGMGenOption(OPTION_NAME_LASTFILE, noteFile.toString());

            if (noteFile.toString().endsWith(EXTENSION)) {
                openGMN(noteFile);
            }
        }
    }

    GMGenSystem.inst.setCursor(originalCursor);
    refreshTree();
}

From source file:fi.hoski.remote.ui.Admin.java

public static ActionListener createActionListener(final Component component,
        final ActionListener actionListener) {
    ActionListener al = new ActionListener() {

        @Override//from   w  w w .  j a  va  2  s.  c o  m
        public void actionPerformed(ActionEvent e) {
            try {
                component.setCursor(busyCursor);
                component.repaint();
                actionListener.actionPerformed(e);
            } finally {
                component.setCursor(defaultCursor);
            }
        }
    };
    return al;
}