简体   繁体   English

Swing JTextArea插入符号事件

[英]Swing JTextArea caret events

Are there any events fired when caret is "blinking"? 插入符号“闪烁”时是否发生任何事件?

(not when position changed or property changed etc, but just blink of caret horizontal line) (不在位置更改或属性更改时显示,而只是插入符号水平线闪烁)

How JTextField displays hint (which is disappears when user starts type): JTextField如何显示提示(用户开始键入时将消失):

在此处输入图片说明

and the same functionality used in JTextArea: 以及JTextArea中使用的相同功能:

在此处输入图片说明

As you can see, while caret is blinkng, the first letter is overwritten. 如您所见,当插入符号闪烁时,第一个字母将被覆盖。

Check the method of DefaultCaret 检查DefaultCaret的方法

protected synchronized void damage(Rectangle r)

You can override it and add your code there 您可以覆盖它并在其中添加代码

It would be great to repaint the hint while caret is blinking in case of JTextArea 在JTextArea的情况下,插入符号闪烁时重绘提示是很棒的

Check out Text Prompt for a solution that display a "hint" in the text field and doesn't not require you to play with the Caret. 请查看“ 文本提示”,以获取在文本字段中显示“提示”并且不需要您使用插入符号的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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