如何让FlowLayout将组件添加到框架的顶部而不是中心?
我正在使用 FlowLayout,我希望我的组件从框架的左上角“流动”到右下角,而不是从屏幕中心开始。 GridLayout 做得很好,但它重新调整了我的组件的大小,我不喜欢这样。我会使用 GridBagLayout,但它太复杂了,我想看看是否可以使用 FlowLayout 做我想做的事情。
I am using FlowLayout and I want my components to be "flow" from the top left of my frame to the bottom right instead of starting in the center of the screen. GridLayout does this fine, but it re-adjusts the size of my components and I don't like that. I would use GridBagLayout but it is so complicated I wanted to see If it is possible to do what I want with FlowLayout.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将其作为参数传递给构造函数
编辑:在获得代码后,我认识到垂直对齐是您的问题。您应该切换到另一个布局来解决此问题,例如:
You can pass it as parameter to the constructor
Edit: After having the code I recognized that the vertical alignment is your issue. You should switch to another layout to fix this, e.g.: