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

The following examples show how to use java.awt.Component#setCursor() . These examples are extracted from open source projects. 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
/**
 * 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 2
Source Project: netbeans   File: CustomizerProviderImpl.java    License: 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 3
Source Project: netbeans   File: CustomizerProviderImpl.java    License: 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 4
Source Project: netbeans   File: TreeView.java    License: 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 5
Source Project: netbeans   File: UnitTab.java    License: 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 6
Source Project: netbeans   File: DockerConnectionVisual.java    License: 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 7
Source Project: portecle   File: FPortecle.java    License: 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 8
Source Project: uima-uimaj   File: MainFrame.java    License: 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 9
Source Project: javamelody   File: MWaitCursor.java    License: 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 10
/**
 * 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 11
private static void setCursorBusy(Component glassPane) {
	glassPane.addMouseListener(new MouseAdapter() {
	});
	glassPane.setVisible(true);

	glassPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}
 
Example 12
Source Project: RipplePower   File: UIRes.java    License: Apache License 2.0 4 votes vote down vote up
private static void setCursor(Cursor cursor, Component component) {
	if (component != null) {
		component.setCursor(cursor);
	}
}
 
Example 13
Source Project: FancyBing   File: GoGui.java    License: GNU General Public License v3.0 4 votes vote down vote up
private void setCursorDefault(Component component)
{
    component.setCursor(Cursor.getDefaultCursor());
}
 
Example 14
/**
 * 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 15
public static void showBusyCursor(Component c) {
    c.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}
 
Example 16
Source Project: netbeans   File: DecorationUtils.java    License: 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 17
void setCursor(int c) {
  final Component root = SwingUtilities.getRoot(this);
  if (root!=null)
    root.setCursor(Cursor.getPredefinedCursor(c));
}
 
Example 18
public static void showHandCursor(Component c) {
    c.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
 
Example 19
@Override
public int getSourceActions(JComponent c) {
	Component glassPane = c.getRootPane().getGlassPane();
	glassPane.setCursor(DragSource.DefaultMoveDrop);
	return MOVE; // COPY_OR_MOVE;
}
 
Example 20
@Override
public int getSourceActions(JComponent c) {
	Component glassPane = c.getRootPane().getGlassPane();
	glassPane.setCursor(DragSource.DefaultMoveDrop);
	return dndConstant;
}