如何在Netbeans平台中使用Lookup监听器和提供者?
嗨
我在理解 netbeans 平台中的 Lookup Api 时遇到问题。
我想要一个模块,scanning-api,其中有一个最终类和一个要实现的接口,应用程序将通过该模块扫描图片,以及一两个模块,这将依赖于该scanning-api模块,并将实现所有功能。
实现模块将从扫描仪扫描图片,我希望它们通知scanning-api模块中的最后一个类有关每次扫描完成的信息,这样我就可以立即通过gui模块将文档一一展示给用户当它们被扫描时。
api 模块不会从 TopComponent 扩展,因为用户交互位于其他模块 gui 中。我对 LookupListener
和 Lookup.Provider
有一点了解,但我不知道该使用哪一个以及在哪里使用。扫描的文档使用第三个模块(称为 common)中的类 ScannedDocumentObject
在模块之间传输。
你能解释一下如何做到这一点(在一些简单的例子中)或者至少在哪里可以找到信息吗? (我用谷歌搜索,但对于lookup.provider,没有那么多例子,我不明白lookup.getdefault或getLookup等之间有什么区别。)我想,我必须在gui模块中使用LookupListener,并且我应该在某个地方实现Lookup.provider,但不知道在哪里。
Hi
I have a problem with understanding the Lookup Api in netbeans Platform.
I want to have one module, scanning-api, where one final class will be and one interface to implement, and the application will scann pictures trough this module, and one or two modules, that will have dependency on this scanning-api module, and will implement all the functionality.
The implementation modules will scan pictures from scanner, and i want them to notify the one final class in scanning-api module about each finished scanning, so I can immediately show the documents to the user one-by-one through gui module, as soon as they are scanned.
The api module will not be extendet from TopComponent, because the user interaction is in other module, gui. I know about LookupListener
and Lookup.Provider
a bit, but I dont know which one to use and where. The scanned documents are transfered between modules using class ScannedDocumentObject
in third module, called common.
can you explain me how to do this (on some simple example) or at least where to find info? (I googled but for lookup.provider there are not so many examples, and I dont understand whats the difference between lookup.getdefault or getLookup etc.) I think, i have to use LookupListener in the gui module, and somewhere I should implement the lookup.provider, but dunno where.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
API 在不同版本之间略有不同,因此最好转到源代码:NetBeans 开发人员列表。有超过十年的邮件列表档案可供细读。对于 Lookup API,此处是一个很好的起点。
The API mutates slightly from release to release, so it's best to go to the source: the NetBeans Developer List. There is over a decade's worth of mailing list archives available for perusal. For the Lookup API, here is a good place to start.