Netbeans Visual Library Tip2 – global SatelliteView using Lookup API

If you build a visual application that provides the abillity to open multiple models, having a global satelliteview, instead of a single one for each scene is pretty much essential. This can be easily done by using the LookupAPI.

First, create a new TopComponent place a JScrollPane on it and name it graphPane.

Then add the following code to your newly created TopComponent.

lookup = Utilities.actionsGlobalContext();
template = new Template(WHEREEVERYOURSCENELIVESIN.class);
results = lookup.lookup(template);
results.addLookupListener(new LookupListener() {

public void resultChanged(LookupEvent ev) {
scenes =  results.allInstances();

JComponent view=null;

for (sceneInterface s: scenes){
graphView = s.getGraphView();
view = graphView.createSatelliteView();

graphPane.setViewportView(view);
}

}
});

}

This assumes that your actual scene or atleast an api-object of it is available via the global Lookup returned by actionsGlobalContext().

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: