Skip to content

Instantly share code, notes, and snippets.

@einnocent
Created September 4, 2013 00:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save einnocent/6431419 to your computer and use it in GitHub Desktop.
Save einnocent/6431419 to your computer and use it in GitHub Desktop.
Simple class for giving Apache Pivot components a blank cursor
import java.awt.Cursor;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import org.apache.pivot.wtk.Component;
// based on http://stackoverflow.com/a/1984117/538222
public class CustomCursor
{
// Create a new blank cursor.
private static final Cursor BLANK_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor(
new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB), new Point(0, 0), "blank cursor");
public static void setBlankCursor(Component component)
{
if (component != null)
{
component.getDisplay().getDisplayHost().setCursor(BLANK_CURSOR);
}
}
}
// make the cursor blank... and keep it blank!
CustomCursor.setBlankCursor(mainPanel);
mainPanel.getComponentMouseListeners().add(new ComponentMouseListener.Adapter()
{
// mouseOver seems like the logical choice, but it didn't work for me
@Override
public boolean mouseMove(Component component, int x, int y)
{
CustomCursor.setBlankCursor(component);
return true;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment