作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以我在小程序的 init()
中有一些类似这样的代码:
layout = new BorderLayout();
setLayout(layout);
northPanel = new JPanel(new FlowLayout());
northPanel.add(inputDropDown);
northPanel.add(lowBoundLabel);
northPanel.add(lowBoundField);
northPanel.add(highBoundLabel);
northPanel.add(highBoundField);
northPanel.add(new JLabel("using"));
northPanel.add(categoriesField);
northPanel.add(new JLabel("categories"));
northPanel.add(showTotalsBox);
northPanel.add(refreshButton);
add(northPanel, BorderLayout.NORTH);
现在,当我测试它时,所有元素都在一条直线上,并且在空间不足时不会环绕。我什至确保指定面板是 FlowLayout (即使它是默认的)并且它没有改变任何东西。
他们不应该换行而不是直接离开屏幕吗?这是怎么回事?我想出了一个临时解决方案,将 northPanel
更改为 BorderLayout
,将这些元素拆分为单独的面板,并将它们添加到 North
和 南
。然而,元素只是从屏幕上消失,而在此方法中没有必要的空间,所以我宁愿让它们环绕起来。
最佳答案
这实际上正是 FlowLayout
的工作原理,很烦人不是吗...
看看WrapLayout
相反...
关于java - 将面板添加到 BorderLayout 区域,元素未按应有的方式换行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16826557/
当我运行我的应用程序时,我在控制台中收到一条消息: 2011-11-16 19:17:41.292 Juice[8674:707] Applications are expected to have
我在 JavaScript 中使用了这个语句,但是当我尝试在 TypeScript 项目中使用它时出现错误。它在提示 fetch(...args) const fetcher = (...args)
我是一名优秀的程序员,十分优秀!