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:com.eviware.soapui.impl.rest.panels.component.RestResourceEditor.java

public RestResourceEditor(final RestResource editingRestResource, MutableBoolean updating) {
    super(editingRestResource.getFullPath());
    this.editingRestResource = editingRestResource;
    this.updating = updating;
    setName(REST_RESOURCE_EDITOR_TEXT_FIELD);

    if (isResourceLonely(editingRestResource)) {
        getDocument().addDocumentListener(new LonelyDocumentListener());
        addFocusListener(new FocusListener() {
            public void focusLost(FocusEvent e) {
                scanForTemplateParameters(editingRestResource);
                removeMatrixParameters();
            }//  w  w w . j a v a2  s  . c  o  m

            /**
             * Matrix parameters should not be added directly on the rest resource.
             * The parameter editor should be used. Hence they are removed from the rest resource editor
             * text field at this time.
             */
            private void removeMatrixParameters() {
                setText(getText().split(";")[0]);
            }

            public void focusGained(FocusEvent e) {
            }
        });

    } else {
        Color originalBackground = getBackground();
        Border originalBorder = getBorder();
        setEditable(false);
        setBackground(originalBackground);
        setBorder(originalBorder);
        setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
        mouseListener = new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                final RestResource focusedResource = new RestResourceFinder(editingRestResource)
                        .findResourceAt(lastSelectedPosition);
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        openPopup(focusedResource);
                    }
                });
            }
        };
        addMouseListener(mouseListener);
        addCaretListener(new CaretListener() {
            @Override
            public void caretUpdate(final CaretEvent e) {
                lastSelectedPosition = e.getDot();
            }

        });
    }
}

From source file:org.jtheque.ui.utils.windows.WindowState.java

@Override
public void startWait() {
    installWaitUIIfNecessary();//from w  ww  .ja  v a2  s  . c  om
    content.setUI(waitUI);
    waitUI.setLocked(true);
    window.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}

From source file:biz.wolschon.finance.jgnucash.actions.ImportPluginMenuAction.java

@Override
public void actionPerformed(final ActionEvent e) {
    try {/*ww w .  j  a v a  2s . com*/
        GnucashWritableFile wModel = myJGnucashEditor.getWritableModel();
        if (wModel == null) {
            JOptionPane.showMessageDialog(myJGnucashEditor, "No open file.",
                    "Please open a gnucash-file first!", JOptionPane.WARNING_MESSAGE);
            return;
        }

        // Activate plug-in that declares extension.
        myJGnucashEditor.getPluginManager().activatePlugin(ext.getDeclaringPluginDescriptor().getId());
        // Get plug-in class loader.
        ClassLoader classLoader = myJGnucashEditor.getPluginManager()
                .getPluginClassLoader(ext.getDeclaringPluginDescriptor());
        // Load Tool class.
        Class toolCls = classLoader.loadClass(ext.getParameter("class").valueAsString());
        // Create Tool instance.
        Object o = toolCls.newInstance();
        if (!(o instanceof ImporterPlugin)) {
            LOGGER.error("Plugin '" + pluginName + "' does not implement ImporterPlugin-interface.");
            JOptionPane.showMessageDialog(myJGnucashEditor, "Error",
                    "Plugin '" + pluginName + "' does not implement ImporterPlugin-interface.",
                    JOptionPane.ERROR_MESSAGE);
            return;

        }
        ImporterPlugin importer = (ImporterPlugin) o;
        try {
            myJGnucashEditor.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            GnucashWritableAccount selectedAccount = (GnucashWritableAccount) myJGnucashEditor
                    .getSelectedAccount();
            String message = importer.runImport(wModel, selectedAccount);
            if (message != null && message.length() > 0) {
                JOptionPane.showMessageDialog(myJGnucashEditor, "Import OK",
                        "The import was a success:\n" + message, JOptionPane.INFORMATION_MESSAGE);
            }
        } catch (Exception e1) {
            LOGGER.error("Import via Plugin '" + pluginName + "' failed.", e1);
            JOptionPane
                    .showMessageDialog(
                            myJGnucashEditor, "Error", "Import via Plugin '" + pluginName + "' failed.\n" + "["
                                    + e1.getClass().getName() + "]: " + e1.getMessage(),
                            JOptionPane.ERROR_MESSAGE);
        } finally {
            myJGnucashEditor.setCursor(Cursor.getDefaultCursor());
        }
    } catch (Exception e1) {
        LOGGER.error("Could not activate requested import-plugin '" + pluginName + "'.", e1);
        JOptionPane
                .showMessageDialog(
                        myJGnucashEditor, "Error", "Could not activate requested import-plugin '" + pluginName
                                + "'.\n" + "[" + e1.getClass().getName() + "]: " + e1.getMessage(),
                        JOptionPane.ERROR_MESSAGE);
    }
}

From source file:org.kalypso.model.wspm.ui.action.selection.AbstractProfilePointSelectionWidget.java

@Override
public void activate(final ICommandTarget commandPoster, final IMapPanel mapPanel) {
    super.activate(commandPoster, mapPanel);

    /* Add myself as selection changed listener. */
    mapPanel.addSelectionChangedListener(m_mapPanelListener);

    /* Initialize widget with the selection. */
    final ISelection selection = mapPanel.getSelection();
    setSelection(new ProfilesSelection(selection));

    /* Reset. *//*from   w  w  w . j  a v a 2 s.c  om*/
    reset();

    /* init the cursor. */
    final Cursor cursor = Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR);
    mapPanel.setCursor(cursor);
}

From source file:EditorPaneExample10A.java

public EditorPaneExample10A() {
    super("JEditorPane Example 10 - using getIterator");

    pane = new JEditorPane();
    pane.setEditable(false); // Read-only
    getContentPane().add(new JScrollPane(pane), "Center");

    // Build the panel of controls
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;/*w ww .  j  av  a2s  .c  o  m*/
    c.gridheight = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    c.weighty = 0.0;

    JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT);
    panel.add(urlLabel, c);
    JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT);
    c.gridy = 1;
    panel.add(loadingLabel, c);
    JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT);
    c.gridy = 2;
    panel.add(typeLabel, c);
    c.gridy = 3;
    panel.add(new JLabel(LOAD_TIME), c);

    c.gridy = 4;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    onlineLoad = new JCheckBox("Online Load");
    panel.add(onlineLoad, c);
    onlineLoad.setSelected(true);
    onlineLoad.setForeground(typeLabel.getForeground());

    c.gridx = 1;
    c.gridy = 0;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;

    urlCombo = new JComboBox();
    panel.add(urlCombo, c);
    urlCombo.setEditable(true);
    loadingState = new JLabel(spaces, JLabel.LEFT);
    loadingState.setForeground(Color.black);
    c.gridy = 1;
    panel.add(loadingState, c);
    loadedType = new JLabel(spaces, JLabel.LEFT);
    loadedType.setForeground(Color.black);
    c.gridy = 2;
    panel.add(loadedType, c);
    timeLabel = new JLabel("");
    c.gridy = 3;
    panel.add(timeLabel, c);

    getContentPane().add(panel, "South");

    // Change page based on combo selection
    urlCombo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (populatingCombo == true) {
                return;
            }
            Object selection = urlCombo.getSelectedItem();
            try {
                // Check if the new page and the old
                // page are the same.
                URL url;
                if (selection instanceof URL) {
                    url = (URL) selection;
                } else {
                    url = new URL((String) selection);
                }

                URL loadedURL = pane.getPage();
                if (loadedURL != null && loadedURL.sameFile(url)) {
                    return;
                }

                // Try to display the page
                urlCombo.setEnabled(false); // Disable input
                urlCombo.paintImmediately(0, 0, urlCombo.getSize().width, urlCombo.getSize().height);
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                // Busy cursor
                loadingState.setText("Loading...");
                loadingState.paintImmediately(0, 0, loadingState.getSize().width,
                        loadingState.getSize().height);
                loadedType.setText("");
                loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height);

                timeLabel.setText("");
                timeLabel.paintImmediately(0, 0, timeLabel.getSize().width, timeLabel.getSize().height);

                startTime = System.currentTimeMillis();

                // Choose the loading method
                if (onlineLoad.isSelected()) {
                    // Usual load via setPage
                    pane.setPage(url);
                    loadedType.setText(pane.getContentType());
                } else {
                    pane.setContentType("text/html");
                    loadedType.setText(pane.getContentType());
                    if (loader == null) {
                        loader = new HTMLDocumentLoader();
                    }
                    HTMLDocument doc = loader.loadDocument(url);
                    loadComplete();
                    pane.setDocument(doc);
                    displayLoadTime();
                    populateCombo(findLinks(doc, null));
                    enableInput();
                }
            } catch (Exception e) {
                System.out.println(e);
                JOptionPane.showMessageDialog(pane,
                        new String[] { "Unable to open file", selection.toString() }, "File Open Error",
                        JOptionPane.ERROR_MESSAGE);
                loadingState.setText("Failed");
                enableInput();
            }
        }
    });

    // Listen for page load to complete
    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                loadComplete();
                displayLoadTime();
                populateCombo(findLinks(pane.getDocument(), null));
                enableInput();
            }
        }
    });
}

From source file:org.jtheque.ui.utils.windows.WindowState.java

@Override
public void stopWait() {
    if (waitUI != null) {
        waitUI.setLocked(false);//  ww  w .  j  ava  2 s .c o m
        window.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
        content.setUI(null);
    }
}

From source file:org.kepler.gui.kar.ActorUploaderAction.java

/**
 * Invoked when an action occurs./*from  w  ww . j  av  a  2 s . c  o m*/
 * 
 *@param e
 *            ActionEvent
 */
public void actionPerformed(ActionEvent e) {
    super.actionPerformed(e);

    ExportActorArchiveAction eaaa = new ExportActorArchiveAction(_parent);
    eaaa.useTempFile = true;
    _parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    eaaa.actionPerformed(e);
    _parent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));

    //      ComponentEntity object;
    //      SaveKAR sk = eaaa.getSaveKAR();
    //      
    //      ArrayList<ComponentEntity> components = sk.getSaveInitiatorList();
    //      if (components.size() == 1) {
    //         object = components.get(0);
    //      } else {
    //         return;
    //      }
    //      
    //      ComponentUploader uploader = new ComponentUploader(_parent);
    //      uploader.upload(sk.getFile(), object);

}

From source file:components.ProgressBarDemo.java

/**
 * Invoked when the user presses the start button.
 *//*from  w  ww  .  j  av a 2  s. com*/
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:com.antelink.sourcesquare.gui.view.ExitSourceSquareView.java

/**
 * Create the frame.//from  ww w. jav a 2s  .c  om
 */
public ExitSourceSquareView() {
    setIconImage(Toolkit.getDefaultToolkit().getImage(SourceSquareView.class.getResource("/antelink.png")));
    setTitle("SourceSquare");
    setResizable(false);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 500, 170);
    this.contentPane = new JPanel();
    this.contentPane.setBackground(Color.WHITE);
    this.contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(this.contentPane);

    this.mainPanel = new JPanel();
    this.mainPanel.setBackground(Color.WHITE);
    GroupLayout gl_contentPane = new GroupLayout(this.contentPane);
    gl_contentPane.setHorizontalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
            .addComponent(this.mainPanel, GroupLayout.DEFAULT_SIZE, 428, Short.MAX_VALUE));
    gl_contentPane.setVerticalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
            .addComponent(this.mainPanel, GroupLayout.DEFAULT_SIZE, 263, Short.MAX_VALUE));
    this.mainPanel.setLayout(new BoxLayout(this.mainPanel, BoxLayout.Y_AXIS));

    JPanel panel_1 = new JPanel();
    panel_1.setBackground(Color.WHITE);
    this.mainPanel.add(panel_1);
    panel_1.setLayout(new BorderLayout(0, 0));

    JPanel panel = new JPanel();
    panel.setLayout(new FlowLayout(FlowLayout.CENTER, 50, 20));
    panel.setBackground(Color.WHITE);
    panel_1.add(panel, BorderLayout.SOUTH);

    Image openButtonImage = Toolkit.getDefaultToolkit()
            .getImage(SourceSquareView.class.getResource("/OpenButton.png"));
    this.openButtonLabel = new JLabel(new ImageIcon(openButtonImage));
    this.openButtonLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    panel.add(this.openButtonLabel);

    JLabel exitLabel = new JLabel("<html><b>Closing this window will quit the application</b></html>");
    exitLabel.setFont(new Font("Helvetica", Font.PLAIN, 13));

    JLabel explainLabel = new JLabel("<html>(You won't be able to see or publish your results anymore)</html>");
    explainLabel.setFont(new Font("Helvetica", Font.PLAIN, 13));

    JPanel textPanel = new JPanel();
    textPanel.setBackground(Color.WHITE);
    textPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 0));

    textPanel.add(exitLabel, BorderLayout.CENTER);
    textPanel.add(explainLabel, BorderLayout.CENTER);

    panel_1.add(textPanel, BorderLayout.CENTER);

    CopyrightPanel copyrightPanel = new CopyrightPanel();
    copyrightPanel.setBackground(Color.WHITE);
    this.mainPanel.add(copyrightPanel);
    this.contentPane.setLayout(gl_contentPane);

    setLocationRelativeTo(null);
}

From source file:StocksTable5.java

public void retrieveData() {
    SimpleDateFormat frm = new SimpleDateFormat("MM/dd/yyyy");
    String currentDate = frm.format(m_data.m_date);
    String result = (String) JOptionPane.showInputDialog(this, "Please enter date in form mm/dd/yyyy:", "Input",
            JOptionPane.INFORMATION_MESSAGE, null, null, currentDate);
    if (result == null)
        return;// ww w.j  a v a  2s. c  o  m

    java.util.Date date = null;
    try {
        date = frm.parse(result);
    } catch (java.text.ParseException ex) {
        date = null;
    }

    if (date == null) {
        JOptionPane.showMessageDialog(this, result + " is not a valid date", "Warning",
                JOptionPane.WARNING_MESSAGE);
        return;
    }

    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    switch (m_data.retrieveData(date)) {
    case 0: // Ok with data
        m_title.setText(m_data.getTitle());
        m_table.tableChanged(new TableModelEvent(m_data));
        m_table.repaint();
        break;
    case 1: // No data
        JOptionPane.showMessageDialog(this, "No data found for " + result, "Warning",
                JOptionPane.WARNING_MESSAGE);
        break;
    case -1: // Error
        JOptionPane.showMessageDialog(this, "Error retrieving data", "Warning", JOptionPane.WARNING_MESSAGE);
        break;
    }
    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}