Example usage for java.awt Cursor getPredefinedCursor

List of usage examples for java.awt Cursor getPredefinedCursor

Introduction

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

Prototype

public static Cursor getPredefinedCursor(int type) 

Source Link

Document

Returns a cursor object with the specified predefined type.

Usage

From source file:edu.uchc.octane.OctanePlugin.java

/**
 * Load dataset from disk/*from w  w  w .  j av a2s  .  c  o  m*/
 * @param f File on disk
 * @return The dataset
 * @throws IOException
 * @throws ClassNotFoundException
 */
TrajDataset readDataset(File f) throws IOException, ClassNotFoundException {

    TrajDataset dataset;

    IJ.getInstance().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    IJ.showStatus("Loading data ...");

    dataset = TrajDataset.loadDataset(f);

    IJ.showStatus("");
    IJ.getInstance().setCursor(Cursor.getDefaultCursor());

    return dataset;
}

From source file:ProgressBarDemo.java

/**
 * Invoked when the user presses the start button.
 *///from   w  w w .ja v a 2  s.co m
public void actionPerformed(ActionEvent evt) {
    startButton.setEnabled(false);
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    // Instances of javax.swing.SwingWorker are not reusuable, so
    // we create new instances as needed.
    task = new Task();
    task.addPropertyChangeListener(this);
    task.execute();
}

From source file:org.ecoinformatics.seek.ecogrid.quicksearch.QuickSearchAction.java

/**
 * The todo Implementation of abstract method. It will search ecogrid site
 * /*w  w w  .jav  a  2s .  c  o m*/
 * @param e
 *            ActionEvent
 */
public synchronized void actionPerformed(ActionEvent e) {
    datasetPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    CacheManager cm;
    try {
        cm = CacheManager.getInstance();
        //cm.showDB();
    } catch (CacheException e1) {
        e1.printStackTrace();
    }
    String searchValue = null;
    if (datasetPanel != null) {
        searchValue = datasetPanel.getSearchTextFieldValue();
        // searchType = datasetPanel.getSearchDataSrcType();
        resultRoot = datasetPanel.getResultRoot();
    }

    //
    // If no search term is entered, return immediately.
    if (searchValue == null || searchValue.trim().equals("")) {
        return;
    }

    System.out.println("searching..");

    searchServicesVector = controller.getSelectedServicesList();
    actionList = new Vector();

    // transfer endpoint based EcoGridService to namespace based Search
    // Scope
    Vector searchScopeVector = transformEcoGridServiceToSearchScope();
    if (!searchScopeVector.isEmpty() && resultRoot != null) {
        resultRoot.removeAllEntities();
        // go through every namespace in search scope
        for (int i = 0; i < searchScopeVector.size(); i++) {
            // vecotr to store the ResultRecord for one search scope
            SearchScope searchScope = (SearchScope) searchScopeVector.elementAt(i);
            // String namespace = searchScope.getNamespace();
            // get quick search query from metadata specification class
            MetadataSpecificationInterface metadataSpecClass = searchScope.getMetadataSpecification();

            // *** Temporary Code
            String namespace = searchScope.getNamespace();

            QueryType quickSearchQuery = null;
            try {
                quickSearchQuery = metadataSpecClass.getQuickSearchEcoGridQuery(searchValue);
            } catch (InvalidEcogridQueryException inE) {
                log.debug("The error to generate quick search query ", inE);
                return;
            }
            Vector searchEndPoints = searchScope.getEndPoints();
            if (searchEndPoints == null) {
                log.debug("No search end points can be found");
                return;
            }

            // go through the end points vector and create query action

            searchEndPointsVector(searchEndPoints, quickSearchQuery, searchValue, metadataSpecClass, namespace);

        } // for
        log.debug("Initial query action ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ " + actionList.size());
        completedRequests = new CountDown(actionList.size());
        // start query action
        datasetPanel.resetResultsPanel();

        boolean forRegistryQuery = false;
        datasetPanel.startSearchProgressBar(forRegistryQuery);
        for (int i = 0; i < actionList.size(); i++) {
            QueryAction queryAction = (QueryAction) actionList.elementAt(i);
            queryAction.actionPerformed(null);
        }

    } // if
    datasetPanel.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}

From source file:ProgressBarDemo.java

/**
 * Called when the user presses the start button.
 *//*from w ww.ja  va2  s  .c om*/
public void actionPerformed(ActionEvent evt) {
    startButton.setEnabled(false);
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    task.go();
    timer.start();
}

From source file:org.kalypso.kalypsomodel1d2d.ui.map.channeledit.LineGeometryEditor.java

public void moved(final GM_Point p) {
    m_startPoint = null;/*from   w  w w .ja  v a2s  . co  m*/

    final GM_Point movedPoint = m_pointSnapper.moved(p);
    if (movedPoint != null) {
        m_curve = m_positionMap.get(movedPoint.getPosition());

        m_handles = collectHandles();

        m_mapPanel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    } else
        m_mapPanel.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));

    repaintMap();
}

From source file:org.revager.tools.GUITools.java

/**
 * Creates a new image button.//  w w  w  .java2s  .  c  om
 * 
 * @param icon
 *            the normal icon
 * @param rolloverIcon
 *            the rollover icon
 * @param action
 *            the action
 * 
 * @return the newly created image button
 */
public static JButton newImageButton(ImageIcon icon, ImageIcon rolloverIcon, Action action) {
    JButton button = new JButton(action);
    button.setToolTipText(button.getText());
    button.setText(null);
    button.setContentAreaFilled(false);
    button.setBorder(new EmptyBorder(0, 0, 0, 0));
    button.setMargin(new Insets(0, 0, 0, 0));
    button.setBorderPainted(false);
    button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    button.setFocusPainted(false);
    button.setFocusable(false);

    button.setIcon(icon);
    button.setRolloverIcon(rolloverIcon);
    button.setRolloverSelectedIcon(rolloverIcon);
    button.setSelectedIcon(rolloverIcon);
    return button;
}

From source file:org.ut.biolab.medsavant.client.filter.TagFilterView.java

public TagFilterView(int queryID) {
    super(FILTER_NAME, queryID);

    setLayout(new BorderLayout());
    setBorder(ViewUtil.getBigBorder());/*from   w w  w  . j  av a  2 s . c o m*/
    setMaximumSize(new Dimension(200, 80));

    JPanel cp = new JPanel();
    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();

    c.gridx = 0;
    c.gridy = 0;

    cp.setLayout(gbl);

    variantTags = new ArrayList<VariantTag>();
    appliedTags = new ArrayList<VariantTag>();

    clear = new JButton("Clear");
    applyButton = new JButton("Apply");

    try {
        final JComboBox tagNameCB = new JComboBox();
        //tagNameCB.setMaximumSize(new Dimension(1000,30));

        final JComboBox tagValueCB = new JComboBox();
        //tagValueCB.setMaximumSize(new Dimension(1000,30));

        JPanel bottomContainer = new JPanel();
        ViewUtil.applyHorizontalBoxLayout(bottomContainer);

        List<String> tagNames = MedSavantClient.VariantManager
                .getDistinctTagNames(LoginController.getSessionID());

        for (String tag : tagNames) {
            tagNameCB.addItem(tag);
        }

        ta = new JTextArea();
        ta.setRows(10);
        ta.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
        ta.setEditable(false);

        applyButton.setEnabled(false);

        JLabel addButton = ViewUtil
                .createIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.ADD));
        addButton.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {

                if (tagNameCB.getSelectedItem() == null || tagValueCB.getSelectedItem() == null) {
                    return;
                }

                VariantTag tag = new VariantTag((String) tagNameCB.getSelectedItem(),
                        (String) tagValueCB.getSelectedItem());
                if (variantTags.isEmpty()) {
                    ta.append(tag.toString() + "\n");
                } else {
                    ta.append("AND " + tag.toString() + "\n");
                }
                variantTags.add(tag);
                applyButton.setEnabled(true);
            }
        });

        clear.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent ae) {
                variantTags.clear();
                ta.setText("");
                applyButton.setEnabled(true);
            }
        });

        int width = 150;

        ta.setPreferredSize(new Dimension(width, width));
        ta.setMaximumSize(new Dimension(width, width));
        tagNameCB.setPreferredSize(new Dimension(width, 25));
        tagValueCB.setPreferredSize(new Dimension(width, 25));
        tagNameCB.setMaximumSize(new Dimension(width, 25));
        tagValueCB.setMaximumSize(new Dimension(width, 25));

        cp.add(new JLabel("Name"), c);
        c.gridx++;
        cp.add(tagNameCB, c);
        c.gridx++;

        c.gridx = 0;
        c.gridy++;

        cp.add(new JLabel("Value"), c);
        c.gridx++;
        cp.add(tagValueCB, c);
        c.gridx++;
        cp.add(addButton, c);

        tagNameCB.addItemListener(new ItemListener() {

            @Override
            public void itemStateChanged(ItemEvent ie) {
                updateTagValues((String) tagNameCB.getSelectedItem(), tagValueCB);
            }
        });

        if (tagNameCB.getItemCount() > 0) {
            tagNameCB.setSelectedIndex(0);
            updateTagValues((String) tagNameCB.getSelectedItem(), tagValueCB);
        }

        al = new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {

                applyButton.setEnabled(false);

                appliedTags = new ArrayList<VariantTag>(variantTags);

                Filter f = new Filter() {

                    @Override
                    public Condition[] getConditions() {
                        try {
                            List<Integer> uploadIDs = MedSavantClient.VariantManager
                                    .getUploadIDsMatchingVariantTags(LoginController.getSessionID(),
                                            TagFilterView.tagsToStringArray(variantTags));

                            Condition[] uploadIDConditions = new Condition[uploadIDs.size()];

                            TableSchema table = MedSavantClient.CustomTablesManager.getCustomTableSchema(
                                    LoginController.getSessionID(),
                                    MedSavantClient.ProjectManager.getVariantTableName(
                                            LoginController.getSessionID(),
                                            ProjectController.getInstance().getCurrentProjectID(),
                                            ReferenceController.getInstance().getCurrentReferenceID(), true));

                            for (int i = 0; i < uploadIDs.size(); i++) {
                                uploadIDConditions[i] = BinaryCondition.equalTo(
                                        table.getDBColumn(BasicVariantColumns.UPLOAD_ID), uploadIDs.get(i));
                            }

                            return new Condition[] { ComboCondition.or(uploadIDConditions) };
                        } catch (Exception ex) {
                            ClientMiscUtils.reportError("Error getting upload IDs: %s", ex);
                        }
                        return new Condition[0];
                    }

                    @Override
                    public String getName() {
                        return FILTER_NAME;
                    }

                    @Override
                    public String getID() {
                        return FILTER_ID;
                    }
                };
                FilterController.getInstance().addFilter(f, TagFilterView.this.queryID);
            }
        };

        applyButton.addActionListener(al);

        bottomContainer.add(Box.createHorizontalGlue());
        bottomContainer.add(clear);
        bottomContainer.add(applyButton);

        add(ViewUtil.getClearBorderedScrollPane(ta), BorderLayout.CENTER);
        add(bottomContainer, BorderLayout.SOUTH);

    } catch (Exception ex) {
        ClientMiscUtils.checkSQLException(ex);
    }

    add(cp, BorderLayout.NORTH);

    this.showViewCard();
}

From source file:org.kalypso.kalypsomodel1d2d.ui.map.channeledit.DrawBanklineWidget.java

@Override
public void mouseMoved(final MouseEvent event) {
    final Point p = event.getPoint();
    if (p == null)
        return;//  ww  w . j a v a2s. co  m

    final IMapPanel mapPanel = getMapPanel();
    if (mapPanel == null)
        return;

    m_currentPos = MapUtilities.transform(getMapPanel(), p);

    if (m_edit && m_bankline != null)
        m_lineEditor.moved(m_currentPos);
    else
        getMapPanel().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));

    repaintMap();
}

From source file:org.omegat.gui.main.ProjectUICommands.java

public static void projectCreate() {
    UIThreadsUtil.mustBeSwingThread();/*from   w w  w .j  a va  2s.c  o  m*/

    if (Core.getProject().isProjectLoaded()) {
        return;
    }

    // ask for new project dir
    NewProjectFileChooser ndc = new NewProjectFileChooser();
    int ndcResult = ndc.showSaveDialog(Core.getMainWindow().getApplicationFrame());
    if (ndcResult != OmegaTFileChooser.APPROVE_OPTION) {
        // user press 'Cancel' in project creation dialog
        return;
    }
    final File dir = ndc.getSelectedFile();

    new SwingWorker<Object, Void>() {
        protected Object doInBackground() throws Exception {

            dir.mkdirs();

            // ask about new project properties
            ProjectProperties props = new ProjectProperties(dir);
            props.setSourceLanguage(Preferences.getPreferenceDefault(Preferences.SOURCE_LOCALE, "EN-US"));
            props.setTargetLanguage(Preferences.getPreferenceDefault(Preferences.TARGET_LOCALE, "EN-GB"));
            ProjectPropertiesDialog newProjDialog = new ProjectPropertiesDialog(
                    Core.getMainWindow().getApplicationFrame(), props, dir.getAbsolutePath(),
                    ProjectPropertiesDialog.Mode.NEW_PROJECT);
            newProjDialog.setVisible(true);
            newProjDialog.dispose();

            IMainWindow mainWindow = Core.getMainWindow();
            Cursor hourglassCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
            Cursor oldCursor = mainWindow.getCursor();
            mainWindow.setCursor(hourglassCursor);

            final ProjectProperties newProps = newProjDialog.getResult();
            if (newProps == null) {
                // user clicks on 'Cancel'
                dir.delete();
                mainWindow.setCursor(oldCursor);
                return null;
            }

            final String projectRoot = newProps.getProjectRoot();

            if (!StringUtil.isEmpty(projectRoot)) {
                // create project
                try {
                    ProjectFactory.createProject(newProps);
                } catch (Exception ex) {
                    Log.logErrorRB(ex, "PP_ERROR_UNABLE_TO_READ_PROJECT_FILE");
                    Core.getMainWindow().displayErrorRB(ex, "PP_ERROR_UNABLE_TO_READ_PROJECT_FILE");
                }
            }

            RecentProjects.add(dir.getAbsolutePath());

            mainWindow.setCursor(oldCursor);
            return null;
        }
    }.execute();
}

From source file:com.ssn.ui.custom.component.SSNImageThumbnailControl.java

public SSNImageThumbnailControl getSsnImageThumbnailControl(String imagePath, int index) {
    //this.setLayout();
    iF = 0;//ww w . ja  v a2 s  . c om
    BufferedImage thumbImg1 = null;
    this.index = index;
    BufferedImage image;
    String[] videoSupported = SSNConstants.SSN_VIDEO_FORMAT_SUPPORTED;
    final List<String> videoSupportedList = Arrays.asList(videoSupported);
    try {

        // add code to check file is video or image  if video then write code to create thumbnail 
        String fileExtention = imagePath.substring(imagePath.lastIndexOf(".") + 1, imagePath.length());
        if (videoSupportedList.contains(fileExtention.toUpperCase())) {

            IMediaReader reader = null;
            try {

                if (true) {
                    reader = ToolFactory.makeReader(imagePath);
                    reader.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR);
                    reader.addListener(new MediaListenerAdapter() {
                        @Override
                        public void onVideoPicture(IVideoPictureEvent event) {
                            setVideoFrame(event.getImage());
                            iF++;
                        }

                    });
                    while (reader.readPacket() == null && iF == 0)
                        ;
                    thumbImg1 = SSNHelper.resizeImage(getVideoFrame(), 50, 50);
                }
            } catch (Throwable e) {
                e.printStackTrace();
            } finally {
                if (reader != null)
                    reader.close();
            }
        } else {
            image = ImageIO.read(new File(imagePath));
            thumbImg1 = SSNHelper.resizeImage(image, 50, 50);
        }

    } catch (IOException ex) {
        Logger.getLogger(SSNImageThumbnailControl.class.getName()).log(Level.SEVERE, null, ex);
    }
    ImageIcon imageIcon = new ImageIcon(thumbImg1);
    JLabel thumbnailLabel = new JLabel(imageIcon, SwingConstants.HORIZONTAL);
    JLabel closeLabel = new JLabel(new ImageIcon(getClass().getResource("/icon/remove-icon.png")),
            SwingConstants.HORIZONTAL);
    closeLabel.setFocusable(true);
    closeLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    this.add(thumbnailLabel);
    this.add(closeLabel);
    closeLabel.addMouseListener(this);

    this.setFocusable(true);
    this.setSize(new Dimension(50, 50));
    this.setBackground(new Color(0, 0, 0, 1));

    return this;
}