2011-12-05 53 views
0

我想爲標籤分配TextField。我使用以下代碼LWUIT:如何將標籤分配給Textfield

TextField textField = new TextField(); 
Label label = new Label("Pick a unique username"); 
textField.setLabelForComponent(label); 
textField.setConstraint(TextField.ANY); 
form.addComponent(textField); 
form.show(); 

上面的代碼不表示在TextField的相關聯的標籤。如何做呢 ?

回答

1

Component從LWUIT的Javadoc @link

public void setLabelForComponent(Label componentLabel) 

Allows us to indicate the label associated with this component thus providing 
visual feedback related for this component e.g. starting the ticker when the 
component receives focus. 

Parameters:  
componentLabel - a label associated with this component 

摘錄因此你只是關聯與此Component現在實際結合在一起感知/視覺單組一個Label

我會建議你使用ComponentGroupTextFieldLabel添加到它,也可以作爲一個組的樣式。檢查ComponentGroup

PS this鏈接,瞭解更多信息:ComponentGroup可從LWUIT 1.5

+0

感謝您的幫助,它真的有效, –

+0

WC,考慮接受這個答案,以幫助未來讀者的這篇文章。 – Vimal