Quantcast
Channel: Oracle Bloggers
Viewing all articles
Browse latest Browse all 19780

Display JavaHelp In Browser Instead Of JavaHelp Window

$
0
0

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.


Viewing all articles
Browse latest Browse all 19780

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>