为什么将Dialog的padding设置为(0,0,0,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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将列表边距也设置为 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.