创建一个 customSuggestionDisplay 类
public static class CustomSuggestionDisplay extends SuggestBox.DefaultSuggestionDisplay {
private PopupPanel suggestionPopupRef;
public CustomSuggestionDisplay() {
suggestionPopupRef = getPopupPanel();
}
public void removeBorder() {
((Element)suggestionPopupRef.getElement().getChild(0)).getStyle().setBackgroundColor("white");
NodeList<com.google.gwt.dom.client.Element> tdList = suggestionPopupRef.getElement().getElementsByTagName("td");
for (int tdIndex = 0; tdIndex < tdList.getLength(); ++tdIndex) {
Element tdElement = (Element) tdList.getItem(tdIndex);
if (tdElement.getClassName().startsWith("suggestPopup"))
tdElement.removeClassName(tdElement.getClassName());
}
}
}
创建一个建议框对象
SuggestOracle oracle = new RestSuggestOracle();
CustomSuggestionDisplay suggestionDisplay = new CustomSuggestionDisplay();
TextBox textfield = new TextBox();
SuggestBox m_field = new SuggestBox(oracle, textfield, suggestionDisplay);
显示建议时调用 removeBorder
if (m_field.isSuggestionListShowing())
suggestionDisplay.removeBorder();