- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何在同一行中设置由 JTextField 分隔的两个 JLabel?我正在使用 MigLayout。我有以下代码
JPanel helper = new JPanel( new MigLayout() );
helper.add( new JLabel( "Threshold:" ), "" );
threshold = new JTextField();
Icon thresholdIcon = UIManager.getIcon( "OptionPane.questionIcon" );
JLabel thresholdIconLabel = new JLabel( thresholdIcon );
thresholdIconLabel.setToolTipText( "Threshold for template matching" );
helper.add( threshold, "wrap, width 100:20" );
helper.add( thresholdIconLabel, "wrap, width 100:20" );
我得到的输出如下所示。
我希望图标与阈值和文本字段位于同一行。我应该如何调整呢?如有任何帮助/建议,我们将不胜感激。
最佳答案
您是否考虑过在放置组件时使用行/列约束并使用“单元格”参数?我用这种方法取得了很大的成功。
JPanel helper = new JPanel(
new MigLayout(
"",
"5[grow,fill]10[grow,fill,20:100]10[grow,fill,20:100]5",
"5[fill,grow]5"));
helper.add( new JLabel( "Threshold:" ), "cell 0 0" );
threshold = new JTextField(); // Assuming this was declared earlier
Icon thresholdIcon = UIManager.getIcon( "OptionPane.questionIcon" );
JLabel thresholdIconLabel = new JLabel( thresholdIcon );
thresholdIconLabel.setToolTipText( "Threshold for template matching" );
helper.add( threshold, "cell 1 0" );
helper.add( thresholdIconLabel, "cell 2 0" );
请务必阅读 MigLayout Whitepaper和 MigLayout Quick Start Guide ,因为他们很好地解释了您可以使用的所有内容。
旁注:
它没有显示在一行中的原因是你告诉 MigLayout 可以换行
组件以适应你给它的空间,包括制作新行以适应。您也可以尝试增加窗口的大小。
尺寸 100:20
转换为最小尺寸 100 像素,但首选尺寸为 20 像素,我不知道 MigLayout 将如何处理这个问题。我在代码中更改了它。
(免责声明:代码未经测试,可能有点粗糙)
关于java - MigLayout:将两个JLabel放在同一行,用JTextField分隔,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52282263/
右侧面板包含所有按钮,我想与底部对齐。 JPanel easternDock = new JPanel(new MigLayout("", "")); easternDock.add(button1,
任何人都可以建议我在哪里可以获得 Miglayout 站点中回调停靠演示应用程序的源代码。这样的教程也可以。谢谢。 最佳答案 有很多断开的链接指向以前的源代码所在的位置。现在演示与 MiG Layou
这里有点不对劲。我试图让最右边的按钮(在下面的示例中标记为“帮助”)与 JFrame 右对齐,并将巨大的按钮的宽度与 JFrame 绑定(bind),但每个按钮至少为 180px。我得到了巨大的按钮约
我正在尝试使结构整齐地居中,但标签和字段之间没有相等的空间,我想我可能不得不使用两列而不是合并它们。 这就是我想要实现的目标: +-----------------------------------
我是新来的,所以对我放宽点。我已经研究了所有关于 miglayout 的文档(顺便说一句,这非常好),但我似乎无法正确显示我想要的网格。 我需要 MigLayout() 参数来设置网格: 2 行,因为
我正在使用 Miglayout 为我的一个面板创建类似表格的布局。我需要所有面板的固定宽度为 200 像素。当我在面板中添加组件时,一切正常,但是当我尝试插入一个具有长文本的按钮(因此需要超过 200
我对 MigLayout 有一些奇怪的行为。我有一个 SSCCE 反射(reflect)了我的问题。基本上,顶部两个面板之间有一个间隙(该间隙属于左侧单元格)。其他一切都如我所愿。仅当 JFrame
我拥有的代码: JPANEL JPanel dadosdaparte = new JPanel(new MigLayout("fillx")); 添加到JPANEL dadosdapa
我有这个面板,它使用 MigLayout 为我的内容创建单元格。这是代码部分: / ====Layout==== setLayout(new MigLayout("hidemode 3
所以我有一个无法解决的问题,我希望我的 GUI 应用程序分为 3 个 JPanel(左、中、右)。我希望左面板和右面板具有固定尺寸,并且中心是流动的。这意味着侧面板仅在 JFrame 展开时垂直展开,
这个问题不太可能对任何 future 的访客有帮助;它只与一个较小的地理区域、一个特定的时间点或一个非常狭窄的情况相关,通常不适用于全世界的互联网受众。如需帮助使此问题更广泛适用,visit the
我有一个扩展类 JComponent 的类,我在其中创建一个带有数字的组件。我想使用 MigLayout 在框架中添加此类对象,但组件没有添加,我只能看到空框架。感谢您的帮助。 用图形创建组件的类 p
我有一个问题想问那些熟悉 MigLayout 或基本 Swing 使用方法的人。 我正在尝试为游戏创建服务器浏览器。 布局最终将如下所示。另外,老实说我不知道该使用什么布局管理器。 +------
我想要发生的是东部和南部的 jetty 移动到窗口的边缘,中间的两个单元填充所有其他空间。相反, jetty 是静态的,拉伸(stretch)窗口只会产生空白空间。 setLayout(new
我正在编写一个应用程序,我希望在其中具有此布局 45% 35% 10% ---------------------
我刚刚开始使用 MigLayout。 我阅读了一些文档,包括 MigLayout 的快速入门指南,并搜索了一些 SO 问题,但没有找到答案。我确信这是显而易见的,但就像我说的,这是我第一次使用这个布局
代码如下: ScreenHeight = Toolkit.getDefaultToolkit().getScreenSize().height, ScreenWidth = Toolkit.getDe
我正在尝试利用 MigLayout 布局管理器创建一个 GUI,允许用户将项目从一个列表移动到另一个列表。我需要箭头靠在一起(垂直)。我遇到的问题是顶部箭头位于单元格的顶部,但我未能成功将其向下移动到
我正在尝试将一个 JTabbedPane 添加到一个面板,上面有用于控件的按钮。我正在使用 MigLayout。 但是,我无法让 JTabbedPane 在按钮不需要时也填充的情况下填充。 参加以下
我目前面临的问题是,有 2 行,MigLayout 似乎强制两个第一个单元格具有相同的宽度,而我希望它们独立工作(注意“Filter”标签太长) ): 除了将两行定义为两个不同的 MigLayout
我是一名优秀的程序员,十分优秀!