gpt4 book ai didi

java - 如何关闭 JEditorPane 中的自动换行?

转载 作者:行者123 更新时间:2023-12-02 06:40:33 24 4
gpt4 key购买 nike

我的 JEditorPane 自动换行;我不想要那个。我想要的只是出现一个水平条,允许用户随心所欲地书写。我怎样才能做到这一点?我尝试了几种方法。我已经覆盖了 getScrollableTracksViewportWidth(),但这没有帮助。有谁知道如何关闭自动换行?

最佳答案

快速谷歌搜索将我带到 this page ,它通过子类化文本 Pane 并覆盖 getScrollableTracksViewportWidth() 方法来实现它:

// Override getScrollableTracksViewportWidth
// to preserve the full width of the text
public boolean getScrollableTracksViewportWidth() {
Component parent = getParent();
ComponentUI ui = getUI();

return parent != null ? (ui.getPreferredSize(this).width <= parent
.getSize().width) : true;
}

关于java - 如何关闭 JEditorPane 中的自动换行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8960732/

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