gpt4 book ai didi

java - JTextArea - 如何在指定偏移处设置文本?

转载 作者:行者123 更新时间:2023-11-29 03:47:56 25 4
gpt4 key购买 nike

我想在我的 JTextArea 中的指定偏移处设置一些文本。假设我已经在我的编辑 "aaa bbb" 中,我想用 "house"覆盖 "bbb",我如何在 Java 中做到这一点?

最佳答案

你可以使用 replaceRange()

public void replaceRange(String str,
int start,
int end)

Replaces text from the indicated start to end position with the new text specified. Does nothing if the model is null. Simply does a delete if the new string is null or empty.

This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.

关于java - JTextArea - 如何在指定偏移处设置文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10061153/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com