KulaDamian
KulaDamian

Reputation: 154

How to change the default caret in a Java application?

I have seen examples that changes the default caret of a single JTextField but is there any function or code that changes the default caret of the whole application to another caret?

Upvotes: 0

Views: 141

Answers (1)

Veera
Veera

Reputation: 276

Component.setCursor is the API that you can use to set the cursor/caret of your choice. However, you should note the contract of this API.

Setting the cursor of a Container causes that cursor to be displayed within all of the container's subcomponents, except for those that have a non-null cursor.

So setting the cursor on the top-most container should probably do it unless it is set in child components.

Note that if you want to create a custom cursor, you would have to use Toolkit.createCustomCursor

Hope this helps.

Upvotes: 1

Related Questions