如何让 JToolBars 换行到下一行 (FlowLayout),而不将它们隐藏在它们下面的 JPanel 中?
我正在制作一个 GUI,它在一个大 JPanel 上方显示三个 JToolBar。这些工具栏总体来说非常大,因此我使用 FlowLayout 使它们在到达 JFrame 边框时换行到下一行。问题是,当它们换行到下一行时,它们会被下面的 JPanel 隐藏。我希望我可以强制包含工具栏的 JPanel 增长到足以显示所有工具栏。
有没有办法做到这一点?或者有其他方法使这些工具栏可见吗?
I am in the process of making a GUI which shows three JToolBars above a big JPanel. These toolbars are collectively very large, so I'm using a FlowLayout to make them wrap to the next line if they reach the JFrame border. The problem is that when they wrap to the next line, they become hidden by the JPanel below.. I wish I could force the JPanel containing the toolbars to grow enough to show all toolbars..
Is there a way to do this? Or is there another way to make these toolbars visible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我以前遇到过这个问题。我发现最好的解决方案是使用 FlowLayout 的修改版本,它考虑了垂直变化并将它们包装到下一行。这是此类布局的代码。
I have run into this problem before. I found the best solution is to use a modified version of
FlowLayout
that takes into account vertical changes and wraps them to the next line. Here is the code for such a layout.看一下 WrapLayout。这对我有用。 这里是代码。
Take a look at WrapLayout. It worked for me. Here is the code.