我正在使用 drawListRow 重新绘制自动完成字段,但我无法设置它的字段高度,这是我的代码:
autoCustomer = new AutoCompleteField(custList, style){
public void drawListRow(ListField clistField, Graphics g,
int index, int y, int width) {
BasicFilteredListResult result = (BasicFilteredListResult)
autoCustomer.get(clistField, index);//);
if (result == null)
return;
String[] stringArray = parseMessage(result._object.toString(), Font.getDefault().derive(Font.PLAIN),fontSize, width-30);
int i;
int yCoord = 0;
int xCoord = 0;
//int rowHeight = (stringArray.length * fontHeight)+3;
clistField.setRowHeight((stringArray.length * fontHeight)+3); //already did this, but it won't work
System.out.println(stringArray.length);
g.setFont( Font.getDefault().derive(Font.PLAIN,fontSize,Ui.UNITS_px));
for(i = 0;i<stringArray.length;i++){
yCoord = y + (fontHeight*(i));
if(i>0)
xCoord = 20;
g.drawText(stringArray[i].trim() , xCoord, yCoord, (DrawStyle.LEFT | DrawStyle.ELLIPSIS | DrawStyle.TOP ), width-20);
}
}
我应该怎么做才能用这个自动完成来制作正确的行高?