java - 如何使用 MigLayout 在 java swing 中制作聊天(whatsapp 之类)ui
问题描述
我想向 MigLayout 添加组件,我可以将其添加为发送/接收的消息,就像这样:
--------------------------------------------
| received message |
| sent Message|
--------------------------------------------
我创建了以下构造函数:
new MigLayout(
// set the automatic wrap after columns
"insets 0, wrap 0",
// hardcode fixed column width and fixed column gap
"",
// hardcode fixed height and a zero row gap
"[]10"));
在添加组件时,如果我使用“推,好吧”它为我完成了这项工作,但组件占用了平均高度空间,如下面的链接所示:
所以我想要的只是这些组件一个接一个,在构造函数中只指定了间隙(10)。谢谢
解决方案
尝试类似:
JPanel parent = JPanel( new BorderLayout() );
parent.add(yourPanelUsingMigLayout, BorderLayout.PAGE_START);
frame.add(parent);
BorderLayout.PAGE_START 将尊重组件的首选高度。因此,您不应该看到组件之间的垂直空间。
推荐阅读
- azure-eventhub - 什么是 bob 容器和检查点
- matlab - 直线和绘图之间的阴影区域
- docker - 我正在尝试在 Ubuntu 20.04.2 LTS 上使用 docker 运行球童服务器,但球童没有启动
- javascript - 使用 JS 更改文本内容
- haskell - 使用 QuickCheck monadicIO 时如何防止测试的函数输出到终端
- python - 线程 django-main-thread django 中的异常
- sql-server - 如何连接PHP7.3、sql server & Nginx Debian10
- sql - Presto sql join 与 intersect-union 哪个性能效率更高
- reactjs - 打字稿反应,基于某个道具值的动态道具?
- regex - egrep 如何在行首和行中搜索具有条件的单词?