Java examples for Swing:Mouse Event
Sets the wait (hourglass) mouse cursor for an application containing component.
//package com.java2s; import java.awt.Cursor; import java.awt.event.MouseAdapter; import javax.swing.JComponent; import javax.swing.RootPaneContainer; public class Main { /**/*w w w . j a v a 2s .c o m*/ * A no-op MouseAdapter used to stop mouse input. */ private static final MouseAdapter noopMouseAdapter = new MouseAdapter() { // nothing to see here }; /** * Sets the wait (hourglass) mouse cursor for an application containing <code>component</code>. * @param component The component to block. */ public static void startWaitCursor(JComponent component) { RootPaneContainer root = (RootPaneContainer) component .getTopLevelAncestor(); root.getGlassPane().setCursor( Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); root.getGlassPane().addMouseListener(noopMouseAdapter); root.getGlassPane().setVisible(true); } }