为什么将Dialog的padding设置为(0,0,0,0)时会出现空格?

发布于 2024-12-11 12:56:07 字数 708 浏览 3 评论 0原文

我向 Dialog 添加了 List。我尝试了所有可能性:

dialog.getContentPane().getSelectedStyle().setPadding(0, 0, 0, 0);
dialog.getContentPane().getUnselectedStyle().setPadding(0, 0, 0, 0);
dialog.getContentPane().getStyle().setPadding(0, 0, 0, 0);
list.getUnselectedStyle().setPadding(Component.LEFT, 0, false);
list.getSelectedStyle().setPadding(Component.LEFT, 0, false);
list.getStyle().setPadding(Component.LEFT, 0, false);

但左侧仍然有一个空格:从 List 渲染器的 getListFocusComponent 返回的彩色 Label 没有。 t 占据Dialog 的所有水平空间!

那么如何让getListFocusComponent()Label 占据Dialog 的所有水平空间:左右?

I added a List to a Dialog. I tried all the possibilities :

dialog.getContentPane().getSelectedStyle().setPadding(0, 0, 0, 0);
dialog.getContentPane().getUnselectedStyle().setPadding(0, 0, 0, 0);
dialog.getContentPane().getStyle().setPadding(0, 0, 0, 0);
list.getUnselectedStyle().setPadding(Component.LEFT, 0, false);
list.getSelectedStyle().setPadding(Component.LEFT, 0, false);
list.getStyle().setPadding(Component.LEFT, 0, false);

but there is still a space gap at the left : the colored Label returned from getListFocusComponent of the List renderer doesn't occupy all the Dialog's horizontal space !

So how to make the Label of the getListFocusComponent() occupy all the Dialog's horizontal space : left and right ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

听风念你 2024-12-18 12:56:07

将列表边距也设置为 0。查看哪个组件负责的最好方法是为它们分配一个边框,这样您就可以看到哪个组件包含填充/边距。请注意,边距位于该边框外部

Set the list margin to 0 as well. The best way to see which component is responsible is to assign them a line border so you can see which component contains the padding/margin. Notice that the margin resides outside of that border.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文