固定位置的 JFrame 布局
哪种布局适合在 JFrame 上定位组件并使它们保持在放置的位置?我不希望控件在调整大小时移动。
Which layout is suitable for positioning components on a JFrame and making them stay where they have been placed? I don't want controls to move around on resizing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议您不要使用空布局,并且不要将组件固定在绝对位置,除非您想要非常丑陋的 GUI,而这些 GUI 很难或不可能在各种操作系统和屏幕分辨率中使用。更好的是甚至不设置任何大小,而是嵌套布局管理器,并让管理器在添加所有组件后通过在顶级窗口(JFrame)上调用 pack 来设置首选和适当的大小。
I suggest that you don't use null layout and that you don't fix your components in absolute position, not unless you want to have very ugly GUI's that are difficult or impossible to use in various operating systems and screen resolutions. Much better is to not even set any sizes but rather to nest layout managers and let the managers set preferred and appropriate sizes by calling pack on your top-level window (the JFrame) after adding all components.
这里解释了使用 null LayoutManager
Use a null LayoutManager explained here