Java - Prevent Resize but keep adding text to JTextArea with JScrollPane

被刻印的时光 ゝ 提交于 2019-12-25 08:57:56

问题


I have made a JTextArea in which I log some info(With an endless loop) I have already set the Preferred Size and added it to a JScrollPane. After logging messages reach the limit of the Jtextarea they stop printing on the screen . I want then to keep printing (and the scrollbar getting smaller and smaller), pretty much like a CMD prompt does. This is necessary because I already have another Jtextfield below and a button


回答1:


Don’t set a preferred size on the JTextArea. Set the preferred size of the JScrollPane instead.



来源:https://stackoverflow.com/questions/18956547/java-prevent-resize-but-keep-adding-text-to-jtextarea-with-jscrollpane

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!