[英]Java Swing text is messed up inside Text Area
I've formatted the result of a query to MySql's style, with all the +----+. 我已经将所有+ ---- +的查询结果格式化为MySql的样式。
In eclipse, the string looks just as I want, but in my GUI, it is messed up: 在eclipse中,字符串看起来像我想要的,但是在我的GUI中,它被弄乱了:
Any idea how can I make the text inside the JTextArea the same as inside eclipse? 知道如何使JTextArea中的文本与eclipse中的文本相同吗?
The text is not messed up, it's just using a non-monospaced font so not all characters have the same width. 文本不会混乱,只是使用非等宽字体,因此并非所有字符都具有相同的宽度。
Just do this to your TextArea: 只需对您的TextArea执行此操作:
textArea.setFont(new Font("Courier New", Font.PLAIN, 12));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.