开发者

Netbeans platform simple window communication

I'm currently using the Netbeans platform and can't seem to get one TopComponent to communicate with another. My research has pointed me in the direction of using Lookups however I can't seem to access my function.

I have one TopComponent called AppleTopComponent, which has a method called myName() and I want to call it from my OrangeTopComponent开发者_开发知识库, which is called within a button handler, inside that handler I have the following code.

TopComponent tc = WindowManager.getDefault().findTopComponent("AppleTopComponent");
Lookup tcLookup = tc.getLookup();
tcLookip.myName();

Surely this should be a simple process, what is it I'm doing wrong.

Many thanks, Alex


This should do what you're looking for.

    TopComponent tc = WindowManager.getDefault().findTopComponent("AppleTopComponent");
    AppleTopComponent atc = (AppleTopComponent) tc;
    jLabel1.setText(atc.myName());
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜