简体   繁体   中英

How to change the default caret in a Java application?

我看过一些示例,这些示例更改了单个JTextField的默认插入记号,但是是否有任何函数或代码将整个应用程序的默认插入记号更改为另一个插入记号?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM