cursor : Java Glossary

*0-9ABCDEFGHIJKLMNOPQRSTUVWXYZ (all)

cursor
Most commonly the cursor refers to the arrow where the mouse is currently pointing. In contrast the caret marks the insertion point where keyed characters will next be inserted in a block of text.
// Set up an hour-glass cursor when the cursor is over myComponent.
// You could use any of the predefined Cursors such as
// WAIT_CURSOR, HAND_CURSOR, DEFAULT_CURSOR, MOVE_CURSOR, CROSSHAIR_CURSOR.
// TEXT_CURSOR or the various resize cursors.

import java.awt.Cursor;
//...
myComponent.setCursor( Cursor.getPredefinedCursor ( Cursor.WAIT_CURSOR ) );
Every Component/ Container can have a different cursor so that the cursor automatically changes shape when the user waves the mouse over each Component.

Normally you just select from one of the pre-dedefined cursors, but you can create a custom cursor with Toolkit. createCustomCursor().

createCustomCursor wants an Image. You can create it in the usual way from a *.png or *.gif file, by fishing it out of a resource. You can also create it with the low-level line and bit drawing tools. It won’t take a *.ico, *.ani or *.bmp file directly. You will have to convert them with utility like IconXP.

Cursor is used more generally for anything that marks a place, e.g. you could call the current seek position in a file a cursor, though in recent times, the term is used exclusively for the mouse cursor.

Installing

Cursors will come as a set of *.cur (static) and *.ani animated images for various cursor purposes. There will also be in an install.inf text file that lists the cursors and their purposes. Usually they will be bundled in a zip. To install:
  1. Unzip the zip file to a temporary directory with WinZip or similar archive utility.
  2. Right click the install.inf file and click install.
  3. Click Start.
  4. Click Control Panel.
  5. Click Hardware and Sound.
  6. Click mouse under Devices and Printers.
  7. Click pointers.
  8. Select the new scheme.

Custom Cursors in HTML (Hypertext Markup Language)

You can override the standard cursor in HTML like this:

<!-- Applying a custom windows cursor over the whole body of the document -->
<!-- Insert this in the head section -->
<style type="text/css">
body{
cursor: url("../cursor/3dorange.cur"),auto;
}
</style>

This works with most Windows browsers such as Internet Explorer, Avant, Chrome, FireFox, SeaMonkey or Safari, but not Opera.

To test your browser’s abilty to change the cursor for just a paragraph, wave the cursor over this text and see if your cursor temporarily changes to an orange cursor.

History

The term originally in Latin meant runner and then was later used for the sliding sight line on a slide rule. From there in computing it came to it meant a marker in a stream and now to its use for the mouse position marker.

Resolution

In Windows 7, cursors can either be 32 × 32 or 48 × 48. Both sizes can be packed into the same file. Windows uses bigger cursors for higher resolution screens. Looking at some modern cursors, it looks as if they now support variable transparency. Axialis makes a utility for designing and packaging cursors. Cursors can have more than one colour, but I don’t know how many or which ones you can choose from. I gather you compose *.png or *.bmp format for each of the cursor shapes, them bundle them into *.ani and *.cur files along with a *.inf installer text file into a *.zip for distribution or embed them in *.exe applications.

Search for custom cursors

Learning More

Oracle’s Javadoc on Cursor class : available:
Oracle’s Javadoc on Toolkit.createCustomCursor : available:

This page is posted
on the web at:

http://mindprod.com/jgloss/cursor.html

Optional Replicator mirror
of mindprod.com
on local hard disk J:

J:\mindprod\jgloss\cursor.html
logo
Please the feedback from other visitors, or your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.

IP:[65.110.21.43]
Your face IP:[54.227.68.206]
You are visitor number