TextField的prefColumnCount属性是什么? [英] What is the prefColumnCount property for a TextField?
本文介绍了TextField的prefColumnCount属性是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I'm reading the docs for TextField, and I came across a property called prefColumnCount. From what I understand, this property controls the size of the text field, but I can't find a definitive answer, and googling yields nothing. What is a text column? How are they measured? Is there anything that isn't obvious that I should know?
推荐答案
在TextFieldSkin
中,您可以使用以下属性找到以下代码段:
In TextFieldSkin
you can find this code snippet using the property:
@Override
protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
TextField textField = getSkinnable();
double characterWidth = fontMetrics.get().computeStringWidth("W");
int columnCount = textField.getPrefColumnCount();
return columnCount * characterWidth + leftInset + rightInset;
}
即通过将属性的值乘以W
的宽度并添加水平插图,可以计算出首选宽度.
I.e. it's used to compute the preferred width by multiplying the value of the property with the width of a W
and adding the horizontal insets.
这篇关于TextField的prefColumnCount属性是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文