如何改变|的颜色的 JTextField

How to change the color of | of JTextField

你知道怎么改变|的颜色吗?在 JTextField 中出现和消失的是什么?由于 JTextField 本身的颜色较深,我看不到它,但我不想更改它,所以我想更改 | 的颜色。 P.S。改变前景的颜色不会影响这件事。还有这个东西怎么叫 ( | ) ?

您需要的缺失信息是 JTextField 中的游标称为 "caret"。

JTextFieldJTextComponent 的子类,它有一个 setCaretColor(...) 方法供您使用。

也许你问的是插入符号的颜色!

这篇 post 将帮助您:

How to change the cursor blink color?