我可以在 BorderLayout 中强制自动换行吗
我想知道是否可以强制 BorderLayout 中的组件像 FlowLayout 中那样换行。
I was wondering if it is possible to force components in BorderLayout to wrap like they do in FlowLayout.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 FlowLayout 时,组件将自动换行。问题是面板的高度不会自动增加,因此您可能永远看不到包裹的组件。 换行布局尝试解决此问题。
When using a FlowLayout the components will wrap automatically. The problem is that the height of the panel does not increase automaically, so you may never see the wrapped components. The Wrap Layout tries to address this issue.
BorderLayout原则上只有5个位置:北、南、东、西、中。如果您想对其中一个位置进行微观管理,最好在其中放置一个 JPanel,并调整其布局(例如,将其设置为 FlowLayout)。
BorderLayout, in principle, have only 5 positions: North, South, East, West and Center. If you want to micro-manage one of those positions, it is best that you put a JPanel there, and tweak its layout (e.g., set it to FlowLayout).