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:Main.java

/**
 * Toggles the cursor for the given component and all child components between
 * the wait cursor and the normal one./*from w ww.  j  av  a2s.c om*/
 */
public static void setWaitCursor(final Component c, final boolean wait) {
    setCursor(c, wait ? Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR) : null);
}

From source file:Main.java

public static WindowAdapter createConfirmOnExitAdapter(final JFrame frame, final String title,
        final String message) {
    frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    return new java.awt.event.WindowAdapter() {
        public void windowClosing(java.awt.event.WindowEvent ev) {
            int result = JOptionPane.showConfirmDialog(frame, message, title, JOptionPane.YES_OPTION);
            if (result == JOptionPane.OK_OPTION) {
                frame.getContentPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                System.exit(0);//  w  ww.j  a v a2 s  .  c  o m
            }
        }
    };
}

From source file:Main.java

private MouseListener getListener() {
    return new MouseAdapter() {
        @Override//from ww w  . j  a  va 2  s  .  c  om
        public void mousePressed(MouseEvent e) {
            super.mousePressed(e);
            pane.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            super.mouseReleased(e);
            pane.setCursor(Cursor.getDefaultCursor());
        }
    };
}

From source file:Main.java

public void run() {
    int count = 0;
    while (animate) {
        try {/*from   ww  w  .j  ava  2  s.c o m*/
            Thread.currentThread().sleep(200);
        } catch (Exception ex) {
        }
        frame.setCursor(cursors[count % cursors.length]);
        count++;
    }
    frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}

From source file:MainClass.java

void dumpComponentInfo(AccessibleContext ac) {
    AccessibleComponent ax = ac.getAccessibleComponent();

    if (ax != null) {
        String s = ac.getAccessibleName();

        if (s != null && s.equals("OK")) {
            System.out.println("Background color: " + ax.getBackground());
            System.out.println("Cursor: " + ax.getCursor());
            Cursor c = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
            ax.setCursor(c);/*from   w w  w.  ja  va2s  .  c  o  m*/
            System.out.println("Foreground color: " + ax.getForeground());
            System.out.println("Location: " + ax.getLocationOnScreen());
        }
    }

    int nChildren = ac.getAccessibleChildrenCount();

    for (int i = 0; i < nChildren; i++)
        dumpComponentInfo(ac.getAccessibleChild(i).getAccessibleContext());
}

From source file:Main.java

public Main() {
    super(new BorderLayout());
    JProgressBar progressBar = new JProgressBar(0, 100);
    progressBar.setValue(0);/*www. ja  v a2  s .  c  o m*/
    progressBar.setStringPainted(true);

    taskOutput = new JTextArea(5, 20);
    taskOutput.setEditable(false);

    startButton = new JButton("Start");
    startButton.setActionCommand("start");
    startButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            startButton.setEnabled(false);
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

            final Task task = new Task();
            task.addPropertyChangeListener(new PropertyChangeListener() {
                @Override
                public void propertyChange(PropertyChangeEvent pce) {
                    if ("progress".equals(pce.getPropertyName())) {
                        int progress = (Integer) pce.getNewValue();
                        progressBar.setValue(progress);
                        taskOutput.append(String.format("Completed %d%% of task.\n", task.getProgress()));
                    }
                }
            });
            task.execute();
        }
    });

    JPanel panel = new JPanel();
    panel.add(startButton);
    panel.add(progressBar);

    add(panel, BorderLayout.PAGE_START);
    add(new JScrollPane(taskOutput), BorderLayout.CENTER);

}

From source file:URLLabel.java

public void mouseEntered(MouseEvent e) {
    setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    entered = true;//from w  w  w . j  a  v  a 2  s .  c om

    if (mousehover) {
        repaint();
    }
}

From source file:Main.java

public Fonts() {
    doc = jta.getStyledDocument();//  www  . j ava  2  s.  co 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:org.argouml.application.Main.java

/**
 * The main entry point of ArgoUML./*from w  ww  .  j  ava 2  s .  co  m*/
 * @param args command line parameters
 */
public static void main(String[] args) {
    try {
        LOG.info("ArgoUML Started.");

        SimpleTimer st = new SimpleTimer();
        st.mark("begin");

        initPreinitialize();

        st.mark("arguments");
        parseCommandLine(args);

        // Register our last chance exception handler
        AwtExceptionHandler.registerExceptionHandler();

        // Get the splash screen up as early as possible
        st.mark("create splash");
        SplashScreen splash = null;
        if (!batch) {
            // We have to do this to set the LAF for the splash screen
            st.mark("initialize laf");
            LookAndFeelMgr.getInstance().initializeLookAndFeel();
            if (theTheme != null) {
                LookAndFeelMgr.getInstance().setCurrentTheme(theTheme);
            }
            if (doSplash) {
                splash = initializeSplash();
            }
        }

        // main initialization happens here
        ProjectBrowser pb = initializeSubsystems(st, splash);

        // Needs to happen after initialization is done & modules loaded
        st.mark("perform commands");
        if (batch) {
            // TODO: Add an "open most recent project" command so that 
            // command state can be decoupled from user settings?
            performCommandsInternal(commands);
            commands = null;

            System.out.println("Exiting because we are running in batch.");
            new ActionExit().doCommand(null);
            return;
        }

        if (reloadRecent && projectName == null) {
            projectName = getMostRecentProject();
        }

        URL urlToOpen = null;
        if (projectName != null) {
            projectName = PersistenceManager.getInstance().fixExtension(projectName);
            urlToOpen = projectUrl(projectName, urlToOpen);
        }

        openProject(st, splash, pb, urlToOpen);

        st.mark("perspectives");
        if (splash != null) {
            splash.updateProgress(75);
        }

        st.mark("open window");
        updateProgress(splash, 95, "statusmsg.bar.open-project-browser");
        ArgoFrame.getFrame().setVisible(true);

        st.mark("close splash");
        if (splash != null) {
            splash.setVisible(false);
            splash.dispose();
            splash = null;
        }

        // Aufrufen der Aufgabenstellung
        if (taskID != null) {
            ActionShowTask task = new ActionShowTask();
            task.showTask();
            if (projectName == null && ActionShowTask.taskDescription != null
                    && (ActionShowTask.taskDescription.toLowerCase().contains("aktivittsdiagramm")
                            || ActionShowTask.taskDescription.toLowerCase().contains("aktivitts-diagramm")
                            || ActionShowTask.taskDescription.toLowerCase().contains("aktivit&auml;tsdiagramm")
                            || ActionShowTask.taskDescription.toLowerCase().contains("aktivit&auml;ts-diagramm")
                            || ActionShowTask.taskDescription.toLowerCase().contains("activity diagram")
                            || ActionShowTask.taskDescription.toLowerCase().contains("activity-diagram"))) {
                new ActionActivityDiagram().actionPerformed(null);
            }
        }

        performCommands(commands);
        commands = null;

        st.mark("start critics");
        Runnable startCritics = new StartCritics();
        Main.addPostLoadAction(startCritics);

        st.mark("start loading modules");
        Runnable moduleLoader = new LoadModules();
        Main.addPostLoadAction(moduleLoader);

        PostLoad pl = new PostLoad(postLoadActions);
        Thread postLoadThead = new Thread(pl);
        postLoadThead.start();

        LOG.info("");
        LOG.info("profile of load time ############");
        for (Enumeration i = st.result(); i.hasMoreElements();) {
            LOG.info(i.nextElement());
        }
        LOG.info("#################################");
        LOG.info("");

        st = null;
        ArgoFrame.getFrame().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));

        // Andreas: just temporary: a warning dialog for uml2...
        if (showUml2warning && Model.getFacade().getUmlVersion().startsWith("2")) {
            JOptionPane.showMessageDialog(ArgoFrame.getFrame(),
                    "You are running an experimental version not meant for productive work!",
                    "UML2 pre-alpha warning", JOptionPane.WARNING_MESSAGE);
        }

        //ToolTipManager.sharedInstance().setInitialDelay(500);
        ToolTipManager.sharedInstance().setDismissDelay(50000000);
    } catch (Throwable t) {
        try {
            LOG.fatal("Fatal error on startup.  ArgoUML failed to start", t);
        } finally {
            System.out.println("Fatal error on startup.  " + "ArgoUML failed to start.");
            t.printStackTrace();
            System.exit(1);
        }
    }
}

From source file:com.cburch.draw.tools.LineTool.java

@Override
public Cursor getCursor(Canvas canvas) {
    return Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR);
}