Example usage for java.awt Cursor WAIT_CURSOR

List of usage examples for java.awt Cursor WAIT_CURSOR

Introduction

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

Prototype

int WAIT_CURSOR

To view the source code for java.awt Cursor WAIT_CURSOR.

Click Source Link

Document

The wait cursor type.

Usage

From source file:Main.java

public Fonts() {
    doc = jta.getStyledDocument();//from w  w w . j ava  2  s.  c o  m
    JScrollPane jsp = new JScrollPane(jta);
    jsp.setPreferredSize(new Dimension(400, 400));
    JFrame frm = new JFrame();
    frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frm.setLayout(new BorderLayout());
    frm.add(jsp, BorderLayout.CENTER);
    frm.setLocation(100, 100);
    frm.pack();
    frm.setVisible(true);
    jta.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    fnt = ge.getAvailableFontFamilyNames();
    mas = jta.getInputAttributes();
    new Thread(this).start();
}

From source file:com.ts.ch.gui.CertifiedHelperController.java

public CertifiedHelperController(PmDatabase database) {
    this.database = database;
    setModelAndView(new CertifiedHelperModel(), new CertifiedHelperView());

    new Task<Void, Void>(Application.getInstance()) {

        public Void doInBackground() {
            CertifiedHelperModel m = (CertifiedHelperModel) CertifiedHelperController.this.getModel();
            CertifiedHelperView v = (CertifiedHelperView) CertifiedHelperController.this.getView();
            v.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

            try {

                dymoAddIn = ClassFactory.createDymoAddIn();
                dymoLabels = ClassFactory.createDymoLabels();

                dymoAddIn.open(LABEL_FILE);

                // Setup printer list
                List<String> printerArray = new ArrayList<String>();
                String prtNames = dymoAddIn.getDymoPrinters();
                if (prtNames != null) {
                    // parse the result
                    String[] names = prtNames.split("\\|");
                    for (String name : names) {
                        printerArray.add(name);
                    }/*from   ww w .j  a  v  a  2s  . co  m*/
                    m.setPrinters(printerArray);

                    prtNames = dymoAddIn.getCurrentPrinterName();
                    if (prtNames != null) {
                        m.setSelectedPrinter(prtNames);
                    } else {
                        m.setSelectedPrinter("");

                    }
                }

                // Check if selected/current printer is a twin tubro printer
                m.setTwinTurboPrinter(dymoAddIn.isTwinTurboPrinter(m.getSelectedPrinter()));
            } catch (Exception e) {

            } finally {
                v.setCursor(Cursor.getDefaultCursor());
            }

            return null;
        }

    }.execute();

}

From source file:ste.travian.gui.WorldChartPanel.java

@Override
public void chartProgress(ChartProgressEvent event) {

    if (event.getType() == ChartProgressEvent.DRAWING_STARTED) {
        mainWindow.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    } else {//w w  w .j av  a  2 s  . c om
        mainWindow.setCursor(Cursor.getDefaultCursor());
    }
}

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

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

    if (this.form.getHiveTree() != null) {
        this.form.getHiveTree().clearSelection();
    }/*from   w  w w .  jav  a2 s  .c  o  m*/
    if (this.form.getInstagramTree() != null) {
        this.form.getInstagramTree().clearSelection();
    }

    if (node.isLeaf()) {
        this.form.setCursor(new Cursor(Cursor.WAIT_CURSOR));
        SSNAlbumNode fnode = null;
        try {
            if (((SSNIconData) node.getUserObject()).getObject() instanceof SSNAlbumNode)
                fnode = (SSNAlbumNode) ((SSNIconData) node.getUserObject()).getObject();
        } catch (ClassCastException ee) {
            ee.printStackTrace();
            this.form.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }
        String facebookDirPath = SSNHelper.getFacebookPhotosDirPath();
        if (fnode != null)
            fileTree.m_display.setText(facebookDirPath + File.separator + fnode);

        SSNIconData iconData = (SSNIconData) node.getUserObject();
        SSNAlbumNode albumNode = (SSNAlbumNode) iconData.getObject();

        MediaOperations mediaOperations = facebook.mediaOperations();

        List<Photo> listPhoto, completePhotoList = new ArrayList<Photo>();
        do {
            PagingParameters pagingParameters = new PagingParameters(100, completePhotoList.size(), null,
                    Calendar.getInstance().getTimeInMillis());
            listPhoto = mediaOperations.getPhotos(albumNode.getAlbum().getId(), pagingParameters);
            completePhotoList.addAll(listPhoto);

        } while (listPhoto.size() > 0);

        createComponents(this.form, completePhotoList, albumNode);
    }

}

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();
    }// w ww .j a  va2s.  c  o  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:EditorPaneExample4.java

public EditorPaneExample4() {
    super("JEditorPane Example 4");

    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  w w .j  a  va2s . 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.gridx = 1;
    c.gridy = 0;
    c.gridwidth = 1;
    c.weightx = 1.0;
    c.fill = GridBagConstraints.HORIZONTAL;

    textField = new JTextField(32);
    panel.add(textField, c);
    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);

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

    // Change page based on text field
    textField.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            String url = textField.getText();

            try {
                // Check if the new page and the old
                // page are the same.
                URL newURL = new URL(url);
                URL loadedURL = pane.getPage();
                if (loadedURL != null && loadedURL.sameFile(newURL)) {
                    return;
                }

                // Try to display the page
                textField.setEnabled(false); // Disable input
                textField.paintImmediately(0, 0, textField.getSize().width, textField.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);
                pane.setPage(url);

                loadedType.setText(pane.getContentType());
            } catch (Exception e) {
                System.out.println(e);
                JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", url },
                        "File Open Error", JOptionPane.ERROR_MESSAGE);
                loadingState.setText("Failed");
                textField.setEnabled(true);
                setCursor(Cursor.getDefaultCursor());
            }
        }
    });

    // Listen for page load to complete
    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                loadingState.setText("Page loaded.");
                textField.setEnabled(true); // Allow entry of new URL
                setCursor(Cursor.getDefaultCursor());
            }
        }
    });
}

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

@Override
public void actionPerformed(final ActionEvent e) {
    try {/*from w w w  .j  a v  a  2  s.c o m*/

        // 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 DataSourcePlugin)) {
            LOGGER.error("Plugin '" + pluginName + "' does not implement DataSourcePlugin-interface.");
            JOptionPane.showMessageDialog(myJGnucashEditor, "Error",
                    "Plugin '" + pluginName + "' does not implement DataSourcePlugin-interface.",
                    JOptionPane.ERROR_MESSAGE);
            return;

        }
        DataSourcePlugin importer = (DataSourcePlugin) o;
        try {
            myJGnucashEditor.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            //workaround because of a deadlock in log4j-consoleAppender in the JPf-classloader
            Logger.getLogger("org.java.plugin.standard.StandardPluginClassLoader").removeAllAppenders();
            Logger.getLogger("org.java.plugin.standard.StandardPluginClassLoader").setLevel(Level.FATAL);
            importer.writeTo(myJGnucashEditor.getWritableModel());
        } catch (Exception e1) {
            LOGGER.error("Write via Plugin '" + pluginName + "' failed.", e1);
            JOptionPane
                    .showMessageDialog(
                            myJGnucashEditor, "Error", "Write 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 Writer-plugin '" + pluginName + "'.", e1);
        JOptionPane
                .showMessageDialog(
                        myJGnucashEditor, "Error", "Could not activate requested Writer-plugin '" + pluginName
                                + "'.\n" + "[" + e1.getClass().getName() + "]: " + e1.getMessage(),
                        JOptionPane.ERROR_MESSAGE);
    }
}

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

@Override
public void actionPerformed(final ActionEvent e) {
    try {// w w w .j  a v  a2 s.co  m

        // 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 DataSourcePlugin)) {
            LOGGER.error("Plugin '" + pluginName + "' does not implement DataSourcePlugin-interface.");
            JOptionPane.showMessageDialog(myJGnucashEditor, "Error",
                    "Plugin '" + pluginName + "' does not implement DataSourcePlugin-interface.",
                    JOptionPane.ERROR_MESSAGE);
            return;

        }
        DataSourcePlugin importer = (DataSourcePlugin) o;
        try {
            myJGnucashEditor.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            //workaround because of a deadlock in log4j-consoleAppender in the JPf-classloader
            Logger.getLogger("org.java.plugin.standard.StandardPluginClassLoader").removeAllAppenders();
            Logger.getLogger("org.java.plugin.standard.StandardPluginClassLoader").setLevel(Level.FATAL);
            GnucashWritableFile loadedFile = importer.loadFile();
            if (loadedFile != null) {
                myJGnucashEditor.setWritableModel(loadedFile);
            }
        } catch (Exception e1) {
            LOGGER.error("Load via Plugin '" + pluginName + "' failed.", e1);
            JOptionPane
                    .showMessageDialog(
                            myJGnucashEditor, "Error", "Load 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 Loader-plugin '" + pluginName + "'.", e1);
        JOptionPane
                .showMessageDialog(
                        myJGnucashEditor, "Error", "Could not activate requested Loader-plugin '" + pluginName
                                + "'.\n" + "[" + e1.getClass().getName() + "]: " + e1.getMessage(),
                        JOptionPane.ERROR_MESSAGE);
    }
}

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

@Override
public void valueChanged(TreeSelectionEvent e) {
    iT = 0;//from  w  ww.j  a v a  2s .co  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: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 .  j  a v a  2 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;
}