且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么这段代码的JTextArea占用了整个JFrame?

更新时间:2023-12-05 20:09:58

默认情况下,JFrame 使用 BorderLayout 。当您只是将某些内容添加到 BorderLayout 组件(如 JFrame )时,它会添加到 BorderLayout (如果你没有指定添加组件的位置),它占用整个 JFrame

JFrame by default uses BorderLayout. When you just add something onto a BorderLayout component like JFrame, it would add to the very center of the BorderLayout (if you did not specify where to add the component), and it takes up the entire JFrame.

您应该使用正确的布局调整它们。

You should use the correct layout to adjust them.