![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the importance of a Cursor class in Java?
A Cursor is a subclass of Object class and it can be defined as point or indicator on the screen. A Cursor is used to select the input from the system that the user operates with the mouse. Different types of cursors available in the Cursor class are DEFAULT_CURSOR, CROSSHAIR_CURSOR, HAND_CURSOR, TEXT_CURSOR, WAIT_CURSOR and etc. The important methods of Cursor class are getDefaultCursor(), getName(), getPredefinedCursor(), getSystemCustomCursor() and getType().
Example
import java.awt.*; import javax.swing.*; public class CursorTest extends JFrame { public CursorTest() { setTitle("Cursor Test"); Cursor cursor = new Cursor(Cursor.HAND_CURSOR); // HAND CURSOR setCursor(cursor); setSize(375, 250); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLocationRelativeTo(null); setVisible(true); } public static void main(String[] args) { new CursorTest(); } }
Output
Advertisements