/**
* Allows to initialize the text box by setting up its listeners and styles.
*/
private void initialize() {
//Set the base values and styles
super.setStyleName( CommonResourcesContainer.GWT_TEXT_BOX_STYLE );
this.addStyleName( CommonResourcesContainer.USER_DIALOG_SUGG_TEXT_BOX_STYLE );
this.setText( helperText );
//On gaining the focus
addFocusHandler(new FocusHandler(){
public void onFocus(FocusEvent event) {
//If the focus is obtained and the text box value is set to empty if
//the user text was not set, i.e. he have the helper message there
if( TextBoxWithSuggText.super.getText().trim().equals( helperText ) ){
TextBoxWithSuggText.super.setText( "" );
}
//Remove the suggestion style making the text be in another color
removeStyleName( CommonResourcesContainer.USER_DIALOG_SUGG_TEXT_BOX_STYLE );
}
});
//On loosing the focus
addBlurHandler(new BlurHandler(){
public void onBlur(BlurEvent e) {
//If the text box looses the focus and the text is not set
//then we set the helper text and the corresponding style
if( TextBoxWithSuggText.super.getText().trim().isEmpty() ){
TextBoxWithSuggText.this.setText( null );
}
}
});
}
TextBoxWithSuggText.java 文件源码
java
阅读 27
收藏 0
点赞 0
评论 0
项目:x-cure-chat
作者:
评论列表
文章目录