Java Swing Cursor startWaitCursor(JComponent component)

Here you can find the source of startWaitCursor(JComponent component)

Description

start Wait Cursor

License

Open Source License

Declaration

public static void startWaitCursor(JComponent component) 

Method Source Code


//package com.java2s;
/*//from   w  w  w .j a  v  a  2s.  co m
 * Copyright (c) 2006, 2009.
 * 
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 * 
 * Created on Apr 19, 2006
 */

import java.awt.Cursor;
import java.awt.event.MouseAdapter;
import javax.swing.JComponent;
import javax.swing.RootPaneContainer;

public class Main {
    private static final Cursor WAIT_CURSOR = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
    private static final MouseAdapter CLICK_CONSUMER = new MouseAdapter() {
        // Empty class (designed to consume all clicks with no effect)
    };

    public static void startWaitCursor(JComponent component) {
        RootPaneContainer root = ((RootPaneContainer) component.getTopLevelAncestor());
        root.getGlassPane().setCursor(WAIT_CURSOR);
        root.getGlassPane().addMouseListener(CLICK_CONSUMER);
        root.getGlassPane().setVisible(true);
        root.getRootPane().validate();
    }
}

Related

  1. showCursor(final Cursor cursor, final Component caller, final boolean includeParent, boolean immediate)
  2. showCursor(final Cursor cursor, final Component caller, final boolean includeParent, boolean immediate)
  3. showDefaultCursor()
  4. showDefaultCursorOnWindow(Component caller)
  5. showDefaultCursorOnWindow(Component caller)
  6. startWaitCursor(JComponent component)
  7. waitCursorOff(Component comp)