Java Swing JtextField插入 [英] Java Swing JtextField inset
问题描述
我正在使用Netbeans GUI,我想在我的jTextField的开头添加3个像素的空间:
I am working with Netbeans GUI and I would like to add 3 pixels of space at the beginning of my jTextField :
我已经尝试过在GUI中使用setMargin,setInset,但是它没有任何改变.
I have tryied with setMargin, setInset in the GUI but it doesn't change anything.
我还有一个问题,为什么右下边框没有四舍五入?这是我的代码:
I have another question, why the bottom right border is not rounded ? here is my code :
Border roundedBorder = new LineBorder(new Color(210,210,210), 1, true);
researchTextField.setBorder(roundedBorder);
非常感谢您
致谢
推荐答案
使用setMargin(...)
应该可以.
但是,如果您还使用边框,则可能是问题所在.
However, if you are also using a Border then that may be the problem.
尝试使用CompoundBorder
,其中内部边框是EmptyBorder(),而外部边框是您的另一个边框.例如:
Try using a CompoundBorder
where the inner border is an EmptyBorder() and the outer border is your other border. For example:
Border rounded = new LineBorder(new Color(210,210,210), 1, true);
Border empty = new EmptyBorder(0, 3, 0, 0);
textField.setBorder(rounded);
Border border = new CompoundBorder(rounded, empty);
为什么右下边框没有四舍五入?
why the bottom right border is not rounded ?
我不确定为什么您的右下角没有四舍五入.在XP上使用Metal LAF,右边界(顶部和底部)显示为圆形,但左边界未显示为圆形.当我使用2或更大的边框大小时,所有角均显示为相等的圆角.
I'm not sure why your bottom/right is not rounded. Using the Metal LAF on XP the right borders (top and bottom) appear rounded but the left borders are not rounded. When I use a border size of 2 or more all corners appear equally rounded.
这篇关于Java Swing JtextField插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!