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:com.ssn.listener.SSNInstagramSelectionListener.java

@Override
public void valueChanged(TreeSelectionEvent event) {
    DefaultMutableTreeNode node = treeHelper.getTreeNode(event.getPath());

    if (this.form.getHiveTree() != null) {
        this.form.getHiveTree().clearSelection();
    }//ww w.j  av  a2 s .co  m

    if (this.form.getFacebookTree() != null) {
        this.form.getFacebookTree().clearSelection();
    }

    if (node.isLeaf()) {
        try {
            this.form.setCursor(new Cursor(Cursor.WAIT_CURSOR));
            String instagramDirPath = SSNHelper.getInstagramPhotosDirPath();
            fileTree.m_display.setText("instagramMedia");
            String urlString = String.format(
                    "https://api.instagram.com/v1/users/self/media/recent/?access_token=%s",
                    accessGrant.getAccessToken());

            List<InstagramMedia> imageList = new ArrayList<>();
            getMedia(urlString, imageList);

            createComponents(this.form, imageList);
        } catch (Exception e) {

        }
    }

}

From source file:Simulator.java

private void AddMouseListeners() {
    map().addMouseListener(new MouseAdapter() {
        @Override//w ww . j  av  a 2  s .  c  o m
        public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
                map().getAttribution().handleAttribution(e.getPoint(), true);
            }
        }
    });

    map().addMouseMotionListener(new MouseAdapter() {
        @Override
        public void mouseMoved(MouseEvent e) {
            Point p = e.getPoint();
            boolean cursorHand = map().getAttribution().handleAttributionCursor(p);
            if (cursorHand) {
                map().setCursor(new Cursor(Cursor.HAND_CURSOR));
            } else {
                map().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
            }
        }
    });
}

From source file:be.tutul.naheulcraft.launcher.auth.LogInForm.java

private void createInterface() {
    setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = 2;// w  ww .j  a v  a  2  s  .c  o m
    constraints.gridx = 0;
    constraints.gridy = -1;
    constraints.weightx = 1.0D;

    add(Box.createGlue());

    JLabel usernameLabel = new JLabel("Pseudo : ");
    Font labelFont = usernameLabel.getFont().deriveFont(1);
    Font smalltextFont = usernameLabel.getFont().deriveFont(labelFont.getSize() - 2.0F);

    usernameLabel.setFont(labelFont);
    add(usernameLabel, constraints);
    add(this.usernameField, constraints);

    add(Box.createVerticalStrut(10), constraints);

    JLabel passwordLabel = new JLabel("Mot de passe :");
    passwordLabel.setFont(labelFont);
    add(passwordLabel, constraints);
    add(this.passwordField, constraints);

    JLabel forgotPasswordLabel = new JLabel("(oubli ?)");
    forgotPasswordLabel.setCursor(new Cursor(12));
    forgotPasswordLabel.setFont(smalltextFont);
    forgotPasswordLabel.setHorizontalAlignment(4);
    forgotPasswordLabel.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            try {
                Util.openLink(Variables.lost);
            } catch (Exception e1) {
                LogInForm.this.login.getLauncher().getLogger()
                        .error("Impossible d'ouvrir le lien pour les logins oublis");
                JOptionPane.showMessageDialog(LogInForm.this.login.getLauncher().getPanel(),
                        "Impossible d'ouvrir la page\nRendez-vous sur le site de NaheulCraft pour rcuprer vos identifiants",
                        "Impossible d'ouvrir l'URL", 0);
            }
        }
    });
    add(forgotPasswordLabel, constraints);

    createUserDropdownPanel(labelFont);
    add(this.userDropdownPanel, constraints);

    add(Box.createVerticalStrut(10), constraints);
}

From source file:de.mendelson.comm.as2.client.HTMLPanel.java

/**Listen to be a HyperlinkListener*/
@Override//  w  w  w . j  av  a 2s. c  o  m
public void hyperlinkUpdate(HyperlinkEvent e) {
    if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
        try {
            URI uri = new URI(e.getURL().toExternalForm());
            Desktop.getDesktop().browse(uri);
        } catch (Exception ex) {
            //nop
        }
    }
    if (e.getEventType() == HyperlinkEvent.EventType.ENTERED) {
        jEditorPane.setCursor(new Cursor(Cursor.HAND_CURSOR));
    }
    if (e.getEventType() == HyperlinkEvent.EventType.EXITED) {
        jEditorPane.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }
}

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

@Override
public void valueChanged(TreeSelectionEvent e) {
    iT = 0;/*w w  w  . ja  va  2  s . c  o m*/
    dT = 0;
    DefaultMutableTreeNode node = treeHelper.getTreeNode(e.getPath());
    List hiveFiles = new ArrayList();
    if (this.form.getHiveTree() != null) {
        this.form.getHiveTree().clearSelection();
    }

    this.form.setCursor(new Cursor(Cursor.WAIT_CURSOR));
    SSNFileNode fnode = null;
    try {
        if (((SSNIconData) node.getUserObject()).getObject() instanceof SSNFileNode) {
            fnode = (SSNFileNode) ((SSNIconData) node.getUserObject()).getObject();
        }
    } catch (ClassCastException ee) {
        logger.error(ee);
        this.form.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }
    getAlbumMedia(form.getHomeModel().getLoggedInUserAccessToken(), 1,
            fileTree.hiveAlbumMap.get(fnode.getFile().getName()));

    /**
     * *******
     *
     */
    if (fnode != null) {

        if (fileTree.m_display.getText() != null && !fileTree.m_display.getText().equals("viewAllAlbums")
                && !fileTree.m_display.getText().equals("instagramMedia")
                && !fileTree.m_display.getText().equals("tagUnTaggedMedia")) {
            fileTree.m_display.setText(fnode.getFile().getAbsolutePath());
        }

        if (fnode.getFile().isDirectory()) {
            this.fileTree.setSelectedFolder(fnode.getFile().getName());
            getSSNMediaFolderProperties(fnode.getFile().getPath());
            File[] file = fnode.getFile().listFiles();
            for (File f : file) {
                if (f.isFile()) {
                    hiveFiles.add(f.getName());
                } else {
                }
            }
        }

        if (hiveFiles != null && hiveFiles.size() > 0) {
            createCompontents(fnode.getFile().getAbsolutePath(), form, true);
        } else {
            createCompontents(fnode.getFile().getAbsolutePath(), form, false);
        }

    } else {

        SSNHelper.toggleDeleteAndShareImages(false, form);
        String path = SSNHelper.getSsnHiveDirPath();
        path = SSNHelper.getSsnTempDirPath();
        form.getFileNamesToBeDeleted().clear();
        getSSNMediaFolderProperties(path);

        if (fileTree.m_display.getText() != null && !fileTree.m_display.getText().equals("viewAllAlbums")
                && !fileTree.m_display.getText().equals("instagramMedia")
                && !fileTree.m_display.getText().equals("tagUnTaggedMedia")) {
            fileTree.m_display.setText(path);
        }

        getForm().ssnFileExplorer.m_tree.setSelectionRow(1);
        long size = FileUtils.sizeOfDirectory(new File(path));

        if (size > 0) {

            File file1 = new File(path);

            if (fileTree.m_display.getText() != null && !fileTree.m_display.getText().equals("viewAllAlbums")
                    && !fileTree.m_display.getText().equals("instagramMedia")
                    && !fileTree.m_display.getText().equals("tagUnTaggedMedia")) {
                fileTree.m_display.setText(file1.getAbsolutePath());
            }
            //just copied from above if block
            if (file1.isDirectory()) {

                this.form.setCurrentSelectedFile(null);
                fileTree.setSelectedFolder(file1.getName());

                File[] file = file1.listFiles();
                for (File f : file) {
                    if (f.isFile()) {
                        hiveFiles.add(f.getName());
                    } else {
                    }
                }
            }

            if (hiveFiles != null && hiveFiles.size() > 0) {

                createCompontents(file1.getAbsolutePath(), form, true);
            } else {
                createCompontents(file1.getAbsolutePath(), form, false);
            }
        } else {
            // show welcome screen
            addWelcomeIcons();
        }
        this.form.getSsnHomeCenterMainPanel().revalidate();
        this.form.getSsnHomeCenterMainPanel().repaint();
        this.form.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }
    this.form.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}

From source file:net.sf.maltcms.chromaui.foldChangeViewer.ui.panel.FoldChangeViewPanel.java

/**
 * Creates new form Chromatogram1DViewPanel
 *//*from  ww w . ja  va  2  s . c  o  m*/
public FoldChangeViewPanel(InstanceContent topComponentInstanceContent, Lookup tcLookup,
        ADataset1D<StatisticsContainer, FoldChangeElement> ds) {
    initComponents();
    this.content = topComponentInstanceContent;
    this.lookup = tcLookup;
    chart = new JFreeChart(new XYPlot());
    chartPanel = new ContextAwareChartPanel(chart, true, true, true, true, true);
    Cursor crosshairCursor = new Cursor(Cursor.CROSSHAIR_CURSOR);
    chartPanel.setCursor(crosshairCursor);
    chartPanel.setInitialDelay(100);
    chartPanel.setDismissDelay(30000);
    chartPanel.setReshowDelay(0);
    chartPanel.setFocusable(true);
    chartPanel.setMouseWheelEnabled(true);
    add(chartPanel, BorderLayout.CENTER);
    content.add(chartPanel);
}

From source file:com.quinsoft.zeidon.objectbrowser.EntitySquare.java

EntitySquare(OiDisplay display, BrowserEnvironment environment, EntityDefLayout layout) {
    super();/*w w w  .jav  a2 s  .co  m*/
    this.env = environment;
    oiDisplay = display;
    entityDefLayout = layout;
    size = new Dimension(SMALLEST_WIDTH * env.getPainterScaleFactor(),
            SMALLEST_HEIGHT * env.getPainterScaleFactor());
    paddedSize = new Dimension((SMALLEST_WIDTH + HORIZONTAL_PAD * 2) * env.getPainterScaleFactor(),
            (SMALLEST_HEIGHT + VERTICAL_PAD * 2) * env.getPainterScaleFactor());
    setSize(size);
    font = new Font(Font.SANS_SERIF, Font.PLAIN, env.getPainterScaleFactor());
    setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    addMouseListener(this);

    getInputMap().put(KeyStroke.getKeyStroke("HOME"), "setFirst");
    getActionMap().put("setFirst", new SetCursorAction(CursorPosition.FIRST));
    getInputMap().put(KeyStroke.getKeyStroke("PAGE_UP"), "setPrev");
    getActionMap().put("setPrev", new SetCursorAction(CursorPosition.PREV));
    getInputMap().put(KeyStroke.getKeyStroke("PAGE_DOWN"), "setNext");
    getActionMap().put("setNext", new SetCursorAction(CursorPosition.NEXT));
    getInputMap().put(KeyStroke.getKeyStroke("END"), "setLast");
    getActionMap().put("setLast", new SetCursorAction(CursorPosition.LAST));

    getInputMap().put(KeyStroke.getKeyStroke("UP"), "moveUp");
    getActionMap().put("moveUp", new ChangeSelectedEntityDefAction(1));
    getInputMap().put(KeyStroke.getKeyStroke("DOWN"), "moveDown");
    getActionMap().put("moveDown", new ChangeSelectedEntityDefAction(2));
    getInputMap().put(KeyStroke.getKeyStroke("LEFT"), "moveLeft");
    getActionMap().put("moveLeft", new ChangeSelectedEntityDefAction(3));
    getInputMap().put(KeyStroke.getKeyStroke("RIGHT"), "moveRight");
    getActionMap().put("moveRight", new ChangeSelectedEntityDefAction(4));

    getInputMap().put(KeyStroke.getKeyStroke("ctrl DOWN"), "resetParent");
    getActionMap().put("resetParent", new ChangeSelectedEntityDefAction(5));
    getInputMap().put(KeyStroke.getKeyStroke("ctrl UP"), "setSubobject");
    getActionMap().put("setSubobject", new ChangeSelectedEntityDefAction(6));
}

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

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

From source file:edu.ku.brc.specify.tasks.subpane.wb.SGRResultsForForm.java

public void refresh() {
    if (currentIndex < 0)
        return;//from w  w w  .j  a v  a 2 s  . c  om

    removeAll();
    repaint();

    if (!sgrPlugin.isReady()) {
        showMessage("SGR_NO_MATCHER");
        return;
    }

    setCursor(new Cursor(Cursor.WAIT_CURSOR));
    new SwingWorker<MatchResults, Void>() {
        private int index = currentIndex;

        @Override
        protected MatchResults doInBackground() throws Exception {
            int modelIndex = workbenchPaneSS.getSpreadSheet().convertRowIndexToModel(index);
            WorkbenchRow row = workbench.getRow(modelIndex);
            return isEmpty(row) ? null : sgrPlugin.doQuery(row);
        }

        @Override
        protected void done() {
            // if we changed indexes in the meantime, don't show this result.
            if (index != currentIndex)
                return;
            //removeAll();

            try {
                results = get();
            } catch (CancellationException e) {
                return;
            } catch (InterruptedException e) {
                return;
            } catch (ExecutionException e) {
                sgrFailed(e);
                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                return;
            }

            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
            if (results == null || results.matches.size() < 1) {
                showMessage("SGR_NO_RESULTS");
                return;
            }

            float maxScore = sgrPlugin.getColorizer().getMaxScore();
            if (maxScore == 0.0f)
                maxScore = 22.0f;

            StringBuilder columns = new StringBuilder("right:max(50dlu;p)");
            for (Match result : results) {
                columns.append(", 4dlu, 150dlu:grow");
            }

            String[] fields = columnOrdering.getFields();
            StringBuilder rows = new StringBuilder();
            for (int i = 0; i < fields.length - 1; i++) {
                rows.append("p, 4dlu,");
            }
            rows.append("p");

            FormLayout layout = new FormLayout(columns.toString(), rows.toString());
            PanelBuilder builder = new PanelBuilder(layout, SGRResultsForForm.this);
            CellConstraints cc = new CellConstraints();

            int y = 1;
            for (String heading : columnOrdering.getHeadings()) {
                builder.addLabel(heading + ":", cc.xy(1, y));
                y += 2;
            }

            int x = 3;
            for (Match result : results) {
                y = 1;
                for (String field : fields) {
                    String value;
                    Color color;
                    if (field.equals("id")) {
                        value = result.match.id;
                        color = SGRColors.colorForScore(result.score, maxScore);
                    } else if (field.equals("score")) {
                        value = String.format("%1$.2f", result.score);
                        color = SGRColors.colorForScore(result.score, maxScore);
                    } else {
                        value = StringUtils.join(result.match.getFieldValues(field).toArray(), "; ");
                        Float fieldContribution = result.fieldScoreContributions().get(field);
                        color = SGRColors.colorForScore(result.score, maxScore, fieldContribution);
                    }

                    JTextField textField = new JTextField(value);
                    textField.setBackground(color);
                    textField.setEditable(false);
                    textField.setCaretPosition(0);
                    builder.add(textField, cc.xy(x, y));
                    y += 2;
                }
                x += 2;
            }
            getParent().validate();
        }
    }.execute();
    UsageTracker.incrUsageCount("SGR.MatchRow");
}

From source file:com.mirth.connect.client.ui.SettingsPanelServer.java

public SettingsPanelServer(String tabName) {
    super(tabName);

    initComponents();//from   w w  w. java  2s .  c om

    addTask(TaskConstants.SETTINGS_SERVER_BACKUP, "Backup Config",
            "Backup your server configuration to an XML file. The backup includes channels, alerts, code templates, server properties, global scripts, and plugin properties.",
            "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/report_disk.png")));
    addTask(TaskConstants.SETTINGS_SERVER_RESTORE, "Restore Config",
            "Restore your server configuration from a server configuration XML file. This will remove and restore your channels, alerts, code templates, server properties, global scripts, and plugin properties.",
            "", new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/report_go.png")));
    addTask(TaskConstants.SETTINGS_CLEAR_ALL_STATS, "Clear All Statistics",
            "Reset the current and lifetime statistics for all channels.", "",
            new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/chart_bar_delete.png")));

    provideUsageStatsMoreInfoLabel.setToolTipText(UIConstants.PRIVACY_TOOLTIP);
    provideUsageStatsMoreInfoLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
    queueBufferSizeField.setDocument(new MirthFieldConstraints(8, false, false, true));
    smtpTimeoutField.setDocument(new MirthFieldConstraints(0, false, false, false));

    defaultMetaDataColumns = new ArrayList<MetaDataColumn>();
}