// Create an additional bar allowing to toggle the edition mode of the web browser.
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 4, 4));
JCheckBox designModeCheckBox = new JCheckBox("Edition Mode (allows to type text or resize elements directly in the page)");
designModeCheckBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
nsIWebBrowser iWebBrowser = MozillaXPCOM.getWebBrowser(webBrowser);
if(iWebBrowser == null) {
JOptionPane.showMessageDialog(webBrowser, "The XPCOM nsIWebBrowser interface could not be obtained.\nPlease check your XULRunner configuration.", "XPCOM interface", JOptionPane.ERROR_MESSAGE);
return;
}
nsIDOMWindow window = iWebBrowser.getContentDOMWindow();
nsIDOMDocument document = window.getDocument();
nsIDOMNSHTMLDocument nsDocument = (nsIDOMNSHTMLDocument)document.queryInterface(nsIDOMNSHTMLDocument.NS_IDOMNSHTMLDOCUMENT_IID);
nsDocument.setDesignMode(e.getStateChange() == ItemEvent.SELECTED? "on": "off");
}
});