X

Geertjan's Blog

  • February 8, 2013

Display JavaHelp In Browser Instead Of JavaHelp Window

Geertjan Wielenga
Product Manager

Thanks to Henry Arousell and Jaroslav Havlin:

import java.net.URL;
import javax.swing.event.ChangeListener;
import org.netbeans.api.javahelp.Help;
import org.openide.awt.HtmlBrowser.URLDisplayer;
import org.openide.util.HelpCtx;
import org.openide.util.lookup.ServiceProvider;
import org.openide.util.lookup.ServiceProviders;
@ServiceProviders({
@ServiceProvider(service = HelpCtx.Displayer.class,
supersedes = {"org.netbeans.modules.javahelp.JavaHelp"}),
@ServiceProvider(service = Help.class,
supersedes = {"org.netbeans.modules.javahelp.JavaHelp"})
})
public class BrowserHelpDisplayer extends Help implements HelpCtx.Displayer {
@Override
public boolean display(HelpCtx hc) {
try {
URLDisplayer.getDefault().showURL(
new URL("http://www.google.com?q="
+ hc.getHelpID()));
} catch (Exception ex) {
return false;
}
return true;
}
@Override
public Boolean isValidID(String id, boolean force) {
return true;
}
@Override
public void showHelp(HelpCtx ctx, boolean showmaster) {
display(ctx);
}
@Override
public void addChangeListener(ChangeListener l) {
}
@Override
public void removeChangeListener(ChangeListener l) {
}
}

The above puts the help ID into Google search. Not helpful in itself, but a starting point for publishing help topics on line, instead of in the JavaHelp window.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.