在JTextArea中插入文本 [英] Inserting text in JTextArea
问题描述
我正在用Java开发一个简单的应用程序,我想知道是否有什么办法可以在光标所在的文本区域内插入其他文本(在句子中间的某处),该区域不是空的放在某些组件的点击上.有人可以指导我如何完成它
如果这是.getCaretPosition 方法
i am developing a simple application in Java and i wanted to know if there is any way i can insert additional text(somewhere in the middle of a sentence) inside a textarea , which is not empty, at a position where the cursor is placed on the click of some component. Can someone please direct me how to go about getting it done
If this is a JTextArea component you can use the .append
method to add text to the end of the text area, or the .insert
method to insert the new text at a specific position.
If you need to insert the text at the current caret position use the .getCaretPosition method
这篇关于在JTextArea中插入文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!