Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以我有一个JTextArea从左上角显示文本的地方。我想要在所有 4 个边上都有一些边距,所以在文本和区域边界之间有一些空间。
JTextArea
我研究了很多,找不到任何解决方案。我该怎么做?
另外,我在想也许可以在所有 4 面都贴上标签以创建虚拟边距。如何创建JLabel具有特定宽度和高度的?
JLabel
可能是我没有正确理解你的问题。但是您可以使用 setMargin()
// set the margin for all four sides tt.setMargin( new Insets(10,10,10,10) ); // tt is JTextArea instance
一些重要的链接
1.setMargin API
2. 类插图