Example usage for java.awt Cursor Cursor

List of usage examples for java.awt Cursor Cursor

Introduction

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

Prototype

protected Cursor(String name) 

Source Link

Document

Creates a new custom cursor object with the specified name.

Note: this constructor should only be used by AWT implementations as part of their support for custom cursors.

Usage

From source file:de.juwimm.cms.gui.admin.PanUnitGroupPerUser.java

public void reload() {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            setCursor(new Cursor(Cursor.WAIT_CURSOR));
            try {
                setPickerEnabled(false);
                tblUser.setEnabled(false);
                userTableModel = new UserTableModel(false);
                TableSorter tblSorter = new TableSorter(userTableModel, tblUser.getTableHeader());

                GroupValue[] groups = null;
                if (!comm.isUserInRole(UserRights.SITE_ROOT)) {
                    groups = comm.getGroups();
                } else {
                    groups = comm.getAllGroups();
                }//w  ww.j a  v  a 2 s .  c  o m
                if (groups != null) {
                    allGroupsOfCaller = new DropDownHolder[groups.length];
                    for (int i = groups.length - 1; i >= 0; i--) {
                        allGroupsOfCaller[i] = new DropDownHolder(groups[i], groups[i].getGroupName());
                    }
                }
                UnitValue[] units = comm.getUnits();
                if (units != null) {
                    allUnits = new DropDownHolder[units.length];
                    for (int i = units.length - 1; i >= 0; i--) {
                        allUnits[i] = new DropDownHolder(units[i], units[i].getName());
                    }
                }

                UserValue[] uv = comm.getAllUser();
                if (uv != null) {
                    if (comm.isUserInRole(UserRights.SITE_ROOT)) {
                        userTableModel.addRows(uv);
                    } else {
                        UserValue me = comm.getUser();
                        for (int i = 0; i < uv.length; i++) {
                            boolean isSiteRoot = comm.isUserInRole(uv[i], UserRights.SITE_ROOT);
                            boolean isMe = uv[i].getUserName().equalsIgnoreCase(me.getUserName());
                            if (!isSiteRoot) {
                                userTableModel.addRow(uv[i]);
                            }
                        }
                    }
                }

                tblUser.setModel(tblSorter);
                unitPickData.getLstLeftModel().clear();
                unitPickData.getLstRightModel().clear();
                groupPickData.getLstLeftModel().clear();
                groupPickData.getLstRightModel().clear();
            } catch (Exception exe) {
                log.error("Error reloading tables: ", exe);
            }
            tblUser.setEnabled(true);
            setCursor(Cursor.getDefaultCursor());
        }
    });
}

From source file:us.paulevans.basicxslt.OutputFrame.java

/**
 * Event handler method.//w  w  w . ja  va 2s.co m
 * 
 * @param aEvt
 */
public void actionPerformed(ActionEvent aEvt) {

    int returnVal;
    File fileToSave;

    setCursor(new Cursor(Cursor.WAIT_CURSOR));
    if (aEvt.getSource() == closeBtn || aEvt.getSource() == close) {
        dispose(userPrefs, PROPERTY_NAME_PREFIX);
    } else if (aEvt.getSource() == transformTimings) {
        new TimingsFrame(this, xslRows);
    } else if (aEvt.getSource() == saveOutputBtn) {
        try {
            returnVal = Utils.getInstance().getFileChooser().showSaveDialog(this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                fileToSave = Utils.getInstance().getFileChooser().getSelectedFile();
                BasicXSLTFrame.setLastFileChosen(fileToSave.getAbsolutePath());
                if (textArea != null) {
                    IOUtils.writeFile(fileToSave, transformResult);
                } else {
                    IOUtils.writeFile(fileToSave, XMLUtils.serialize(node, lastTransformOutputProps));
                }
            }
        } catch (Throwable aAny) {
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
            logger.error(ExceptionUtils.getFullStackTrace(aAny));
            Utils.showErrorDialog(this, aAny);
        }
    }
}

From source file:com.ssn.listener.SSNInstagramSelectionListener.java

private void createComponents(SSNHomeForm ssnHomeForm, List<InstagramMedia> completePhotoList) {
    SSNHelper.toggleDeleteAndShareImages(false, ssnHomeForm);

    try {//  ww  w .  ja  v a 2 s . com
        List<File> listOfFiles = new ArrayList<File>();

        File instagramPhotosDir = new File(SSNHelper.getInstagramPhotosDirPath());
        if (!instagramPhotosDir.exists()) {
            instagramPhotosDir.mkdir();
        }

        for (InstagramMedia photo : completePhotoList) {
            String imageUrl = photo.getImageUrl();

            URL url = new URL(imageUrl);
            File file = new File(SSNHelper.getInstagramPhotosDirPath() + photo.getId() + ".jpg");
            if (!file.exists()) {
                try {
                    FileUtils.copyURLToFile(url, file);
                    listOfFiles.add(file);
                } catch (Exception e) {
                    // e.printStackTrace();
                }
            } else {
                listOfFiles.add(file);
            }
        }

        File[] fileArray = listOfFiles.toArray(new File[0]);
        SSNGalleryHelper contentPane = new SSNGalleryHelper(fileArray, ssnHomeForm);
        contentPane.setBackground(SSNConstants.SSN_BLACK_BACKGROUND_COLOR);

        ssnHomeForm.getSsnHomeCenterPanel().removeAll();
        ssnHomeForm.getSsnHomeCenterMainPanel().removeAll();

        ssnHomeForm.getSsnHomeCenterPanel().add(ssnHomeForm.getScrollPane(contentPane,
                SSNHelper.getAlbumNameFromPath(ssnHomeForm.ssnFileExplorer.m_display.getText())));
        ssnHomeForm
                .getSsnHomeCenterMainPanel().add(
                        ssnHomeForm.getSortPanel("Date", false,
                                SSNHelper
                                        .getAlbumNameFromPath(ssnHomeForm.ssnFileExplorer.m_display.getText())),
                        BorderLayout.NORTH);
        ssnHomeForm.getSsnHomeCenterMainPanel().add(ssnHomeForm.getSsnHomeCenterPanel(), BorderLayout.CENTER);
        ssnHomeForm.getHomeModel().getSSNMediaFolderProperties(
                ssnHomeForm.getHomeModel().getHomeForm().ssnFileExplorer.m_display.getText(), fileArray);
        //ssnHomeForm.add(ssnHomeForm.getSsnHomeCenterMainPanel());

        //             ssnHomeForm.getSplitPane().setLeftComponent(ssnHomeForm.getSsnHomeLeftMainPanel());
        //             ssnHomeForm.getSplitPane().setRightComponent(ssnHomeForm.getSsnHomeCenterMainPanel());
        //                //ssnHomeForm.getSplitPane().setDividerLocation(200);
        //             ssnHomeForm.getSplitPane().revalidate();
        //             ssnHomeForm.getSplitPane().repaint();
        ssnHomeForm.revalidate();
        ssnHomeForm.repaint();
        ssnHomeForm.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.projity.pm.graphic.graph.GraphInteractor.java

protected Cursor getSplitCursor() {
    if (splitCursor == null) {
        try {//from   ww  w. j  a  v  a  2  s  . c  o  m
            splitCursor = Toolkit.getDefaultToolkit().createCustomCursor(
                    IconManager.getImage("gantt.split.cursor"), new Point(10, 4), "splitCursor");
        } catch (Exception e) {
            splitCursor = new Cursor(Cursor.HAND_CURSOR);
        }
    }
    return splitCursor;
}

From source file:net.vanosten.dings.swing.SummaryView.java

/**
 * Shows the chosen grahp in the display area.
 *//*w w w . j ava  2s  . c  om*/
private void showChart() {
    this.setCursor(new Cursor(Cursor.WAIT_CURSOR)); //will be set back in placeChart()
    AppEvent evt = new AppEvent(AppEvent.EventType.DATA_EVENT);
    switch (chartTypeCB.getSelectedIndex()) {
    case 0:
        evt.setMessage(MessageConstants.Message.D_SUMMARY_VIEW_DISPLAY_UNITS);
        break;
    case 1:
        evt.setMessage(MessageConstants.Message.D_SUMMARY_VIEW_DISPLAY_CATEGORIES);
        break;
    case 2:
        evt.setMessage(MessageConstants.Message.D_SUMMARY_VIEW_DISPLAY_ENTRYTYPES);
        break;
    case 3:
        evt.setMessage(MessageConstants.Message.D_SUMMARY_VIEW_DISPLAY_SCORES);
        break;
    default:
        evt.setMessage(MessageConstants.Message.D_SUMMARY_VIEW_DISPLAY_TIMELINE);
        break;
    }
    evt.setDetails(Boolean.toString(chosenCB.isSelected()));
    controller.handleAppEvent(evt);
}

From source file:net.sf.mzmine.modules.peaklistmethods.peakpicking.adap3decompositionV2.ADAP3DecompositionV2SetupDialog.java

@Override
public void actionPerformed(ActionEvent e) {
    super.actionPerformed(e);

    final Object source = e.getSource();

    if (source.equals(chkPreview)) {
        if (chkPreview.isSelected()) {
            // Set the height of the chkPreview to 200 cells, so it will span
            // the whole vertical length of the dialog (buttons are at row
            // no 100). Also, we set the weight to 10, so the chkPreview
            // component will consume most of the extra available space.
            mainPanel.add(pnlPlots, 3, 0, 1, 200, 10, 10, GridBagConstraints.BOTH);
            pnlUIElements.add(pnlComboBoxes, BorderLayout.CENTER);
            //                cboPeakLists.setSelectedIndex(0);
        } else {//from w  w w. j a  v a  2  s.c o  m
            mainPanel.remove(pnlPlots);
            pnlUIElements.remove(pnlComboBoxes);
        }

        updateMinimumSize();
        pack();
        setLocationRelativeTo(MZmineCore.getDesktop().getMainWindow());

        retTimeCluster();
    }

    else if (source.equals(cboClusters)) {
        Cursor cursor = this.getCursor();
        this.setCursor(new Cursor(Cursor.WAIT_CURSOR));

        shapeCluster();

        this.setCursor(cursor);
    }
}

From source file:com.projity.pm.graphic.graph.GraphInteractor.java

public Cursor selectCursor() {
    Cursor cursor = defaultCursor;
    switch (state) {
    case BAR_MOVE:
        cursor = new Cursor(Cursor.MOVE_CURSOR);
        break;//from w  ww. j av a2 s . c om
    case LINK_CREATION:
        cursor = getLinkCursor();
        break;
    case LINK_SELECTION:
        cursor = new Cursor(Cursor.CROSSHAIR_CURSOR);
        break;
    }
    getGraph().setCursor(cursor);
    return cursor;
}

From source file:com.github.benchdoos.weblocopener.updater.gui.UpdateDialog.java

private void createGUI() {
    setContentPane(contentPane);/*from  ww  w  .j ava2s .  c o m*/
    getRootPane().setDefaultButton(buttonOK);
    if (IS_WINDOWS_XP) {
        //for windows xp&server 2003
        setIconImage(Toolkit.getDefaultToolkit()
                .getImage(UpdateDialog.class.getResource("/images/updaterIcon64_white.png")));
    } else {
        setIconImage(Toolkit.getDefaultToolkit()
                .getImage(UpdateDialog.class.getResource("/images/updaterIcon64.png")));

    }

    createDefaultActionListeners();

    // call onCancel() when cross is clicked
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            onCancel();
        }
    });

    // call onCancel() on ESCAPE
    contentPane.registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    updateInfoButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            onUpdateInfoButton();
        }
    });

    updateInfoButton.setCursor(new Cursor(Cursor.HAND_CURSOR));

    manualDownloadButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            openSetupUrl();
        }

        private void openSetupUrl() {
            log.debug("Calling to download setup manually");
            URL url = null;
            if (updater != null) {
                if (updater.getAppVersion() != null) {
                    try {
                        log.debug("Trying to open [" + updater.getAppVersion().getDownloadUrl() + "]");
                        url = new URL(updater.getAppVersion().getDownloadUrl());
                        UrlValidator urlValidator = new UrlValidator();
                        UserUtils.openWebUrl(url);
                    } catch (MalformedURLException e1) {
                        openWebsite(url);
                    }
                } else
                    UserUtils.openWebUrl(ApplicationConstants.UPDATE_WEB_URL);

            } else
                UserUtils.openWebUrl(ApplicationConstants.UPDATE_WEB_URL);
        }

        private void openWebsite(URL url) {
            log.warn("Could not open setup url: [" + url + "]\n" + "Opening "
                    + ApplicationConstants.UPDATE_WEB_URL);
            UserUtils.openWebUrl(ApplicationConstants.UPDATE_WEB_URL);
        }
    });

    pack();
    setLocation(FrameUtils.getFrameOnCenterLocationPoint(this));
    setSize(new Dimension(400, 170));
    setResizable(false);
}

From source file:com.github.cric.app.ui.SettingPanel.java

private Component helpLabel() {

    JLabel help = new JLabel(HELP_TEXT);
    help.addMouseListener(new MouseAdapter() {

        @Override/*from   w ww  . java 2s.c o m*/
        public void mouseEntered(MouseEvent e) {

            help.setCursor(new Cursor(Cursor.HAND_CURSOR));
        }

        @Override
        public void mouseExited(MouseEvent e) {

            help.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }

        @Override
        public void mouseClicked(MouseEvent e) {

            if (Desktop.isDesktopSupported()) {
                try {
                    Desktop.getDesktop().browse(HELP_PAGE);
                } catch (Exception ex) {
                    LOG.warn("unable to open link", ex);
                }
            }
        }
    });
    return help;
}

From source file:org.gitools.ui.core.components.boxes.DetailsBox.java

private Component createValueLabel(DetailsDecoration property, int maxLength) {

    String value = property.getFormatedValue();
    boolean abbreviate = (value.length() > maxLength);
    String abbreviatedValue;//from  w  ww .  j a va2 s.  c  o  m

    if (value.matches("[0-9\\.]+e-?[0-9]+")) {
        value = "<html><body>" + value.replaceAll("e(-?[0-9]+)", "10<sup>$1</sup>") + "</body></html>";
    }

    if (abbreviate) {
        abbreviatedValue = StringUtils.abbreviate(value, maxLength);
    } else {
        abbreviatedValue = value;
    }

    WebLabel label;
    if (StringUtils.isEmpty(property.getValueLink())) {
        label = new WebLabel(abbreviatedValue);
    } else {
        DetailsWebLinkLabel webLabel = new DetailsWebLinkLabel(abbreviatedValue);
        webLabel.setLink(property.getValueLink(), false);
        label = webLabel;
    }

    SwingUtils.changeFontSize(label, -1);

    if (abbreviate) {
        TooltipManager.setTooltip(label, value, TooltipWay.down, 0);
    }

    label.setCursor(new Cursor(Cursor.HAND_CURSOR));
    label.addMouseListener(new PropertyMouseListener(property));

    if (property.isSelected()) {
        SwingUtils.setBoldFont(label);
    }

    if (property.getBgColor() != null) {
        WebPanel colorBox = new WebPanel();
        colorBox.setPreferredSize(new Dimension(15, 15));
        colorBox.setBackground(property.getBgColor());
        return new GroupPanel(4, colorBox, label);
    }

    return label;
}