NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

how to reference to other topcomponent

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Developers
View previous topic :: View next topic  
Author Message
mcheung63



Joined: 18 Dec 2014
Posts: 144
Location: Hong Kong

PostPosted: Thu Oct 06, 2016 6:03 pm    Post subject: how to reference to other topcomponent Reply with quote

Hi
how to reference to other topcomponent? I have a button in one topcomponent and want to change the text in other topcomponent.

thanks
from Peter



net.png
 Description:
 Filesize:  163.37 KB
 Viewed:  2656 Time(s)

net.png


Back to top
Wade Chandler
Posted via mailing list.





PostPosted: Thu Oct 06, 2016 11:05 pm    Post subject: how to reference to other topcomponent Reply with quote

The mailing list you want for working with the platform is address-removed ([email]address-removed[/email]). This list is about NetBeans project development.
There are various ways to do what you want to do, such as common listeners attached to something discovered in the default lookup, which could be put there by some common plugin or support class, or you can do that using the idea of a Central Lookup. See http://wadechandler.blogspot.com/2007/12/central-lookup-creating-central.html
Wade
On Oct 6, 2016 6:49 PM, "mcheung63" <address-removed ([email]address-removed[/email])> wrote:
Quote:
Hi
   how to reference to other topcomponent? I have a button in one topcomponent and want to change the text in other topcomponent.

thanks
from Peter




Attachments:
http://forums.netbeans.org//files/net_179.png

Back to top
DannyBear



Joined: 12 Nov 2009
Posts: 7

PostPosted: Fri Oct 07, 2016 12:49 am    Post subject: how to reference to other topcomponent Reply with quote

Unsubscribe


On Thu, Oct 6, 2016 at 11:03 AM, mcheung63 <address-removed ([email]address-removed[/email])> wrote:
Quote:
Hi
   how to reference to other topcomponent? I have a button in one topcomponent and want to change the text in other topcomponent.

thanks
from Peter




Attachments:
http://forums.netbeans.org//files/net_179.png

Back to top
Wade Chandler
Posted via mailing list.





PostPosted: Fri Oct 07, 2016 12:56 am    Post subject: how to reference to other topcomponent Reply with quote

See https://netbeans.org/community/lists/top.html to unsubscribe ... Mailing lists use email commands. Notice the unsubscribe buttons. Click the right one, and the details will be filled in.
On Oct 6, 2016 8:49 PM, "dlraby" <address-removed ([email]address-removed[/email])> wrote:
Quote:
Unsubscribe


On Thu, Oct 6, 2016 at 11:03 AM, mcheung63 <address-removed ([email]address-removed[/email])> wrote:
Quote:
Hi
   how to reference to other topcomponent? I have a button in one topcomponent and want to change the text in other topcomponent.

thanks
from Peter




Attachments:
http://forums.netbeans.org//files/net_179.png





Back to top
mcheung63



Joined: 18 Dec 2014
Posts: 144
Location: Hong Kong

PostPosted: Fri Oct 07, 2016 8:17 am    Post subject: Reply with quote

now i got a super simple solution, create a Global class:

public class Global {
public static SymbolWindowTopComponent window;
}

then self register the window in the static variable:

Global.window = this;

finally in other window, i can:

Global.window.jLabel1.setText("peter");

BUT IS IT NORMAL? ANY HIDDEN DISADVANTAGE FOR THIS METHOD?

thanks
from Peter
Back to top
bruehlicke



Joined: 18 Sep 2009
Posts: 201
Location: Houston

PostPosted: Fri Oct 07, 2016 6:53 pm    Post subject: Reply with quote

As Wade suggested, go to the NetBeans Platform Users forum. But to get you started go to https://netbeans.org/kb/trails/platform.html and take the time to go through some of the tutorials - it will become so much easier after.
Back to top
mcheung63



Joined: 18 Dec 2014
Posts: 144
Location: Hong Kong

PostPosted: Fri Oct 07, 2016 7:08 pm    Post subject: Reply with quote

thanks bruehlicke
Back to top
pblemel



Joined: 31 Mar 2009
Posts: 158

PostPosted: Fri Oct 07, 2016 9:59 pm    Post subject: how to reference to other topcomponent Reply with quote

Hi Peter,


This is not a good design choice. The SymbolWindowTopComponent should be listening for changes and updating itself, instead of making a member variable public and allowing other classes to update it. For a modular design it is best to use something called a 'lookup'.


https://platform.netbeans.org/tutorials/nbm-selection-1.html
NetBeans Selection Management Tutorial for NetBeans Platform
platform.netbeans.org
NetBeans Selection Management Tutorial I—Using a TopComponent's Lookup. This tutorial covers how to write components that provide a "selected object" and how ...


Regards,

Peter





From: mcheung63 <address-removed>
Sent: Friday, October 7, 2016 2:17 AM
To: address-removed
Subject: [nbdev] how to reference to other topcomponent


now i got a super simple solution, create a Global class:

public class Global {
public static SymbolWindowTopComponent window;
}

then self register the window in the static variable:

Global.window = this;

finally in other window, i can:

Global.window.jLabel1.setText("peter");

BUT IS IT NORMAL? ANY HIDDEN DISADVANTAGE FOR THIS METHOD?

thanks
from Peter
Back to top
mcheung63



Joined: 18 Dec 2014
Posts: 144
Location: Hong Kong

PostPosted: Fri Oct 14, 2016 5:38 am    Post subject: Reply with quote

thanks pblemel
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Developers All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo