How do I set Mozilla preferences from Java when using the SWT browser widget?
1 answer
You can use JavaXPCOM . Something like this should work:
import org.mozilla.xpcom.Mozilla;
import org.mozilla.interfaces.nsIServiceManager;
import org.mozilla.interfaces.nsIPrefBranch;
...
Mozilla mozilla = Mozilla.getInstance();
nsIServiceManager serviceManager = mozilla.getServiceManager();
nsIPrefBranch prefs = (nsIPrefBranch)serviceManager
.getServiceByContractID("@mozilla.org/preferences-service;1",
nsIPrefBranch.NS_IPREFBRANCH_IID);
prefs.setBoolPref("javascript.enabled", false);
If you cannot access JavaXPCOM, this is hardly doable.
+2
source to share