我应该使用哪种布局来按顺序用 JButton 填充 JLayeredPane?
我想按顺序填充 JLayeredPane
,以便当它到达右边距时,它应该从下一行开始并用按钮填充整个框。我想设计一个销售点屏幕,但我很难手动排列按钮。
I want to fill the JLayeredPane
in a order so that when it reaches the right margin it should then start from the next line ans fill the entire box with buttons. I want to design a Point Of Sale screen and its hard for me to arrange the buttons manually.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我理解正确的话,您希望布局管理器自动包装组件。也许 FlowLayout 的默认行为对您来说就足够了。
否则,通过子类化 LayoutManager 或 LayoutManager2 来开发自己的布局管理器实际上相当容易。提示:看看其他简单的布局管理器是如何实现的,以判断任务的复杂程度。
If I understand correctly, you want the layout manager to auto wrap the components. Maybe the default behavior of the FlowLayout is enough for you.
Otherwise, it is actually fairly easy to develop your own layout manager by subclassing LayoutManager or LayoutManager2. Tip: see how other simple layout managers are implemented to judge the complexity of the task.