Created
September 4, 2013 00:36
Simple class for giving Apache Pivot components a blank cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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