我正在使用ContentProposalAdapter來自動完成文本框,它的工作正常,但我想改變其外觀像彈出式的字體或背景顏色,等等,我搜索了但我不能找到任何ContentProposalAdapter的方法來做這些事情。我如何改變一個ContentProposalAdapter的外觀?如何改變ContentProposalAdapter的外觀
2
A
回答
3
我沒有這個JFace的一部分的任何經驗,但是當你查看文檔,你可以找到方法openProposalPopup
(see docs)
這個類提供了一些重寫的方法,以允許客戶端手動控制彈出。但是,大部分實施仍然是私人的。
打開提案彈出窗口並顯示提案提供者提供的提案。此方法立即返回。也就是說,它不會等待提案被選中。子類使用此方法顯式調用彈出窗口的打開。如果沒有要顯示的提議,則彈出窗口不會打開併發出嘟嘟聲。
如果選中該方法的代碼,你會發現
/**
* Open the proposal popup and display the proposals provided by the
* proposal provider. If there are no proposals to be shown, do not show the
* popup. This method returns immediately. That is, it does not wait for the
* popup to open or a proposal to be selected.
*
* @param autoActivated
* a boolean indicating whether the popup was autoactivated. If
* false, a beep will sound when no proposals can be shown.
*/
private void openProposalPopup(boolean autoActivated) {
if (isValid()) {
if (popup == null) {
// Check whether there are any proposals to be shown.
recordCursorPosition(); // must be done before getting proposals
IContentProposal[] proposals = getProposals();
if (proposals.length > 0) {
if (DEBUG) {
System.out.println("POPUP OPENED BY PRECEDING EVENT"); //$NON-NLS-1$
}
recordCursorPosition();
popup = new ContentProposalPopup(null, proposals);
popup.open();
popup.getShell().addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent event) {
popup = null;
}
});
internalPopupOpened();
notifyPopupOpened();
} else if (!autoActivated) {
getControl().getDisplay().beep();
}
}
}
}
/**
* Open the proposal popup and display the proposals provided by the
* proposal provider. This method returns immediately. That is, it does not
* wait for a proposal to be selected. This method is used by subclasses to
* explicitly invoke the opening of the popup. If there are no proposals to
* show, the popup will not open and a beep will be sounded.
*/
protected void openProposalPopup() {
openProposalPopup(false);
}
的代碼創建ContentProposalPopup
實例,它管理彈出窗口小部件和其他一些東西(see source code of whole ContentProposalAdapeter class)的外觀。
因此,如果您將創建新的類,它會覆蓋openProposalPopup()
,將使用自己的ContentProposalPopup
,你可以,只要你想管理的外觀..
1
我們有問題與ContentProposalAdapter
,也和最終副本 - 根據我們的需要進行修改。
相關問題
- 1. 如何改變我的MKMapViewAnnotation的外觀
- 2. 如何改變JasperViewer的外觀?
- 3. 數據表,如何改變外觀
- 4. eclipse的外觀改變了
- 5. 如何改變外觀或改善VB.NET應用程序的外觀?
- 6. TK按鈕改變外觀
- 7. Java eclipse WindowBuilder,改變外觀
- 8. jQuery驗證:改變外觀
- 9. 改變我的NSIS的外觀
- 10. 暫停的javascript腳本改變外觀
- 11. 在Iframe內改變網站的外觀
- 12. JavaScript改變滾動元素的外觀
- 13. 改變偏好活動的外觀
- 14. 改變單選按鈕的外觀
- 15. 如何在java中改變被禁用的JButton的外觀
- 16. 如何更改UITableView的外觀?
- 17. 如何更改ListPreference **按鈕的外觀**
- 18. 如何更改ProgressDialog的外觀?
- 19. 如何更改文本框的外觀
- 20. 如何修改Sharepoint網站的外觀?
- 21. 如何更改果園的外觀
- 22. 如何更改asset_path的外觀?
- 23. 如何更改webpart的外觀?
- 24. 如何更改MenuStrip的外觀
- 25. 如何更改UITableViewController旋轉的外觀?
- 26. 如何更改Android中AutoCompleteTextView的外觀
- 27. 如何改變Python運算符的外觀?
- 28. 你如何改變鍵盤快速搜索欄的外觀?
- 29. 如何在Java中改變按鈕的外觀
- 30. 如何改變EditText的顏色/外觀select handle/anchor?
我明白了你的想法,但是有一個問題,這個方法使用彈出對象,它是私有的,子類沒有任何訪問權限。 – Hekmatof
當然,你必須編寫你自己的類,並在override'openProposalPopup()'方法中使用它。但是你可以使用原來的'ContentProposalPopup'類的一些代碼,不需要編寫整個類,只需要改變你想要的東西,並使用你的實現.. – Sorceror
我認爲我應該改變popup對象的屬性來改變彈出窗口的外觀。如果我是對的,我應該可以訪問彈出對象 – Hekmatof