在JTextArea中插入文本 [英] Inserting text in JTextArea

查看:121
本文介绍了在JTextArea中插入文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用Java开发一个简单的应用程序,我想知道是否有什么办法可以在光标所在的文本区域内插入其他文本(在句子中间的某处),该区域不是空的放在某些组件的点击上.有人可以指导我如何完成它

解决方案

如果这是 解决方案

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆