Java Code Examples for java.awt.Component#setCursor()

The following examples show how to use java.awt.Component#setCursor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UnitTab.java    From netbeans with Apache License 2.0 5 votes vote down vote up
void setWaitingState (boolean waitingState) {
    boolean enabled = !waitingState;
    Component[] all = getComponents ();
    for (Component component : all) {
        if (component == bTabAction || component == bDeactivate || component == bUninstall) {
            if (enabled) {
                TabAction a = (TabAction) ((AbstractButton)component).getAction();
                component.setEnabled (a == null ? false : a.isEnabled());
            } else {
                component.setEnabled (enabled);
            }
        } else {
            if (component == spTab) {
                spTab.getLeftComponent ().setEnabled (enabled);
                spTab.getRightComponent ().setEnabled (enabled);
                details.setEnabled (enabled);
                table.setEnabled (enabled);
            } else {
                component.setEnabled (enabled);
            }
        }
    }
    if (reloadAction != null) {
        reloadAction.setEnabled (enabled);
    }
    Component parent = getParent ();
    Component rootPane = getRootPane ();
    if (parent != null) {
        parent.setEnabled (enabled);
    }
    if (rootPane != null) {
        if (enabled) {
            rootPane.setCursor (null);
        } else {
            rootPane.setCursor (Cursor.getPredefinedCursor (Cursor.WAIT_CURSOR));
        }
    }
    focusTable ();
}
 
Example 2
Source File: CursorUtil.java    From keystore-explorer with GNU General Public License v3.0 5 votes vote down vote up
private static void setCursorBusy(Component glassPane) {
	glassPane.addMouseListener(new MouseAdapter() {
	});
	glassPane.setVisible(true);

	glassPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}
 
Example 3
Source File: CursorController.java    From audiveris with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Wraps an action listener with a busy cursor if not performed within delay.
 *
 * @param component          owner of cursor
 * @param mainActionListener real listener to be wrapped
 * @return the wrapped listener
 */
public static ActionListener createListener (final Component component,
                                             final ActionListener mainActionListener)
{
    ActionListener actionListener = new ActionListener()
    {
        @Override
        public void actionPerformed (final ActionEvent ae)
        {
            TimerTask timerTask = new TimerTask()
            {
                @Override
                public void run ()
                {
                    component.setCursor(busyCursor);
                }
            };

            Timer timer = new Timer();

            try {
                timer.schedule(timerTask, delay);
                mainActionListener.actionPerformed(ae);
            } finally {
                timer.cancel();
                component.setCursor(defaultCursor);
            }
        }
    };

    return actionListener;
}
 
Example 4
Source File: MWaitCursor.java    From javamelody with Apache License 2.0 5 votes vote down vote up
/**
 * Restore l'ancien curseur, en fin de traitement.
 */
public void restore() {
	if (window instanceof RootPaneContainer) {
		final Component glassPane = ((RootPaneContainer) window).getGlassPane();
		glassPane.setVisible(windowGlassPaneVisible);
		glassPane.setCursor(oldWindowCursor);
	}
	if (window != null) {
		window.setCursor(oldWindowCursor);
	}
}
 
Example 5
Source File: MainFrame.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the wait cursor.
 */
private final void setWaitCursor() {
  this.setEnabled(false);
  this.cursorCache = new ArrayList<>();
  for (int i = 0; i < this.cursorOwningComponents.size(); i++) {
    Component comp = this.cursorOwningComponents.get(i);
    this.cursorCache.add(comp.getCursor());
    comp.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
  }
}
 
Example 6
Source File: FPortecle.java    From portecle with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set cursor to busy and disable application input. This can be reversed by a subsequent call to setCursorFree.
 */
private void setCursorBusy()
{
	// Block all mouse events using glass pane
	Component glassPane = getRootPane().getGlassPane();
	glassPane.addMouseListener(new MouseAdapter()
	{
		// Nothing
	});
	glassPane.setVisible(true);

	// Set cursor to busy
	glassPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}
 
Example 7
Source File: DockerConnectionVisual.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void setWaitingState(boolean wait) {
    Component rootPane = getRootPane();
    configPanel.setInputEnabled(!wait);
    testButton.setEnabled(!wait);
    if (rootPane != null) {
        rootPane.setCursor(wait ? Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR) : null);
    }
}
 
Example 8
Source File: RepositoryTreeDialog.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Invoked when an action occurs.
 */
public void actionPerformed( final ActionEvent e ) {
  final CreateNewRepositoryFolderDialog newFolderDialog =
      new CreateNewRepositoryFolderDialog( RepositoryTreeDialog.this );

  if ( !newFolderDialog.performEdit() ) {
    return;
  }

  final TreePath selectionPath = repositoryBrowser.getSelectionPath();
  if ( selectionPath == null ) {
    return;
  }

  final FileObject treeNode = (FileObject) selectionPath.getLastPathComponent();
  if ( !StringUtils.isEmpty( newFolderDialog.getName() ) ) {
    final Component glassPane = SwingUtilities.getRootPane( RepositoryTreeDialog.this ).getGlassPane();
    try {
      glassPane.setVisible( true );
      glassPane.setCursor( new Cursor( Cursor.WAIT_CURSOR ) );
      final FileObject child = treeNode.resolveFile( newFolderDialog.getFolderName() );
      if ( child instanceof WebSolutionFileObject ) {
        final WebSolutionFileObject webSolutionFileObject = (WebSolutionFileObject) child;
        webSolutionFileObject.setDescription( newFolderDialog.getDescription() );
      }
      child.createFolder();
      repositoryTreeModel.fireTreeDataChanged();
      repositoryBrowser.setSelectionPath( selectionPath.getParentPath().pathByAddingChild( child ) );
      setDirty( true );
    } catch ( Exception e1 ) {
      UncaughtExceptionsModel.getInstance().addException( e1 );
    } finally {
      glassPane.setVisible( false );
      glassPane.setCursor( new Cursor( Cursor.DEFAULT_CURSOR ) );
    }
  }
}
 
Example 9
Source File: TreeView.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static void doShowWaitCursor (Component glassPane, boolean show) {
    if (show) {
        glassPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        glassPane.setVisible(true);
    } else {
        glassPane.setVisible(false);
        glassPane.setCursor(null);
    }
}
 
Example 10
Source File: CustomizerProviderImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void run() {
    try {
        JFrame f = (JFrame) WindowManager.getDefault().getMainWindow();
        Component c = f.getGlassPane();
        c.setVisible(show);
        c.setCursor(show ? Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR) : null);
    } catch (NullPointerException npe) {
        Exceptions.printStackTrace(npe);
    }
}
 
Example 11
Source File: CustomizerProviderImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void run() {
    try {
        JFrame f = (JFrame) WindowManager.getDefault().getMainWindow();
        Component c = f.getGlassPane();
        c.setVisible(show);
        c.setCursor(show ? Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR) : null);
    } catch (NullPointerException npe) {
        Exceptions.printStackTrace(npe);
    }
}
 
Example 12
Source File: DecorationUtils.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void mouseExited(MouseEvent e) {
    Component comp = (Component)e.getSource();
    comp.setCursor(Cursor.getDefaultCursor());
}
 
Example 13
Source File: StatusBar.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
void setCursor(int c) {
  final Component root = SwingUtilities.getRoot(this);
  if (root!=null)
    root.setCursor(Cursor.getPredefinedCursor(c));
}
 
Example 14
Source File: MouseHelper.java    From magarena with GNU General Public License v3.0 4 votes vote down vote up
public static void showBusyCursor(Component c) {
    c.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}
 
Example 15
Source File: MouseHelper.java    From magarena with GNU General Public License v3.0 4 votes vote down vote up
public static void showHandCursor(Component c) {
    c.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
 
Example 16
Source File: ShowToolSettingsPanel.java    From jeveassets with GNU General Public License v2.0 4 votes vote down vote up
@Override
public int getSourceActions(JComponent c) {
	Component glassPane = c.getRootPane().getGlassPane();
	glassPane.setCursor(DragSource.DefaultMoveDrop);
	return MOVE; // COPY_OR_MOVE;
}
 
Example 17
Source File: RepositoryPublishDialog.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Invoked when an action occurs.
 */
public void actionPerformed( final ActionEvent e ) {
  final CreateNewRepositoryFolderDialog newFolderDialog =
      new CreateNewRepositoryFolderDialog( RepositoryPublishDialog.this );

  if ( !newFolderDialog.performEdit() ) {
    return;
  }

  final FileObject treeNode = getSelectedView();
  if ( treeNode == null ) {
    return;
  }

  while ( !PublishUtil.validateName( newFolderDialog.getFolderName() ) ) {
    JOptionPane.showMessageDialog( RepositoryPublishDialog.this, Messages.getInstance()
        .formatMessage( "PublishToServerAction.IllegalName", newFolderDialog.getFolderName(),
            PublishUtil.getReservedCharsDisplay() ), Messages.getInstance().getString(
        "PublishToServerAction.Error.Title" ), JOptionPane.ERROR_MESSAGE );
    if ( !newFolderDialog.performEdit() ) {
      return;
    }
  }

  final Component glassPane = SwingUtilities.getRootPane( RepositoryPublishDialog.this ).getGlassPane();
  try {
    glassPane.setVisible( true );
    glassPane.setCursor( new Cursor( Cursor.WAIT_CURSOR ) );
    final FileObject child =
        treeNode
            .resolveFile( newFolderDialog.getFolderName().replaceAll( "\\%", "%25" ).replaceAll( "\\!", "%21" ) );
    child.createFolder();
    if ( child instanceof WebSolutionFileObject ) {
      final WebSolutionFileObject webSolutionFileObject = (WebSolutionFileObject) child;
      webSolutionFileObject.setDescription( newFolderDialog.getDescription() );
    }
    getTable().refresh();
  } catch ( Exception e1 ) {
    UncaughtExceptionsModel.getInstance().addException( e1 );
  } finally {
    glassPane.setVisible( false );
    glassPane.setCursor( new Cursor( Cursor.DEFAULT_CURSOR ) );
  }
}
 
Example 18
Source File: GoGui.java    From FancyBing with GNU General Public License v3.0 4 votes vote down vote up
private void setCursorDefault(Component component)
{
    component.setCursor(Cursor.getDefaultCursor());
}
 
Example 19
Source File: ExtendedJListTransferHandler.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public int getSourceActions(JComponent c) {
	Component glassPane = c.getRootPane().getGlassPane();
	glassPane.setCursor(DragSource.DefaultMoveDrop);
	return dndConstant;
}
 
Example 20
Source File: UIRes.java    From RipplePower with Apache License 2.0 4 votes vote down vote up
private static void setCursor(Cursor cursor, Component component) {
	if (component != null) {
		component.setCursor(cursor);
	}
}