0
public final class BrowserTopComponent extends TopComponent implements ActionListener, ChangeListener, LookupListener{
public BrowserTopComponent() {
initComponents();
setName(NbBundle.getMessage(BrowserTopComponent.class, "CTL_BrowserTopComponent"));
setToolTipText(NbBundle.getMessage(BrowserTopComponent.class, "HINT_BrowserTopComponent"));
// setIcon(ImageUtilities.loadImage(ICON_PATH, true));
Browser1 fff = new Browser1();
associateLookup(Lookups.singleton(fff));
}
private Lookup.Result result = null;
@Override
public void componentOpened() {
result = Utilities.actionsGlobalContext().lookupResult(Browser1.class);
result.addLookupListener (this);
}
@Override
public void componentClosed() {
result.removeLookupListener (this);
result = null;
}
private void navButtonActionPerformed(java.awt.event.ActionEvent evt) {
fff.navgiateTo(); // NET BEAN COMPLAINS AT THIS LINE.
}
爲什麼我不能使用fff.navigateTo();但是,當fff.navigateTo()在BrowserTopComponent的構造函數中時,它工作正常!那麼,爲什麼我不能在構造函數之外擁有它?無法訪問提供者類的方法
在我的瀏覽器模塊(其中加載第三方JAR),我有下面的類:
package my.app.browser
import bunch.of.3rd.party.stuff
public class Browser1 {
private String url;
public void navigateTo() {
System.out.println(url);
}
}