简体   繁体   中英

Java Swing text is messed up inside Text Area

I've formatted the result of a query to MySql's style, with all the +----+.

In eclipse, the string looks just as I want, but in my GUI, it is messed up: 在此处输入图片说明

Any idea how can I make the text inside the JTextArea the same as inside 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.setFont(new Font("Courier New", Font.PLAIN, 12));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM