Here you can find the source of setCursorDefault(Container cont)
Parameter | Description |
---|---|
cont | the current Window, Panel, Dialog, or other JComponent; just pass 'this', as long as it's a Container |
public static void setCursorDefault(Container cont)
//package com.java2s; /*L//from w w w.jav a 2s .com * Copyright SAIC, SAIC-Frederick. * * Distributed under the OSI-approved BSD 3-Clause License. * See http://ncip.github.com/caadapter/LICENSE.txt for details. */ import javax.swing.*; import java.awt.*; public class Main { /** * Sets the cursor to default. Should be called AFTER time-intensive task has finished. * Re-enables the mouse pointer for the current window. * * @param cont the current Window, Panel, Dialog, or other JComponent; * just pass 'this', as long as it's a Container */ public static void setCursorDefault(Container cont) { if (cont == null) { System.err.println( "setCursorDefault(Container cont): Container argument cannot be null. Will return and do nothing."); return; } Component glasspane = null; if (cont instanceof RootPaneContainer) { glasspane = ((RootPaneContainer) cont).getGlassPane(); } else if (cont instanceof JComponent) { glasspane = ((JComponent) cont).getRootPane().getGlassPane(); } Window window = SwingUtilities.windowForComponent(glasspane); window.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); glasspane.setVisible(false); } }