If you have a question about JExplorer and it is not listed in this FAQ, please send it to us using the support forum and we will add it here after answering to you. Can I embed Internet Explorer into a Swing container? Can I use Internet Explorer without displaying any windows?Yes, JExplorer provides both these capabilities. There are two classes: Browser (a Swing component) and HeadlessBrowser (a class for automated testing without GUI).How to get source of the HTML document?Load a page using HeadlessBrowser instance and get the HTML document source by calling the WebBrowser.getContent() method:WebBrowser browser = new HeadlessBrowser(); Attached files: CreateHeadlessBrowserSample.java How to embed Internet Explorer into a Swing container?Create a Browser component, add it into a Swing container:Browser browser = new Browser(); How to get an element in the HTML document as a Java object?The WebBrowser.getDocument() method returns org.w3c.dom.Document object that can be used for finding elements in a document. The code below searches for the submit button by name:public void execute(){ Attached files: SubmitFormSample.java, DomNavigationSample.java How to get/set attributes of an element?Find the element in the document and then call the org.w3c.dom.Document.getAttribute() or setAttribute() methods:Element login = browser.getDocument().getElementById("i1"); Attached files:ElementAttributesSample.java How to navigate to a link in the HTML document?Find the link in the page and call the DomRobot.click() method:Element groupsLink = browser.getDocument().getElementById("2a"); Attached files: NavigateLinkSample.java How to fill the form controls in an HTML document with specified values?Find a control in a document, then set the "value" attribute for a text field, "checked" attribute for a checkbox, "selected" attribute for a radio button:browser.navigate("http://google.com"); Attached files: SubmitFormSample.java How to submit a form to the server?Find a submit button of the form and click the button using the DomRobot.click() method:Element searchButton = getSearchButton(browser.getDocument()); Attached files: SubmitFormSample.java How to execute JavaScript code?Use the Browser.executeScript(String) method:// Get JavaScript counter variable String counter = (String)browser.executeScript("counter");Attached files: JavascriptSample.java How to listen to events from the document elements in Java code?Add an event listener to an element:private void setupChangeListener(final org.w3c.dom.Element select){ Is there any easy way to find the absolute screen position for a org.w3c.dom.html.HTMLElement ?To obtain the absolute screen position of any org.w3c.dom.html.HTMLElement, you will need to cast an instance of such element to the HTMLElement interface from com.jniwrapper.win32.ie.dom package and then use its getAbsoluteLocation() method. For example:HTMLElement htmlElement = (HTMLElement)element; Which methods should I use instead of deprecated methods of the DomRobot class?The HTMLElement interface contains element-specific methods and HTMLDocument interface contains document-specific methods. The WebBrowser.setSilent(boolean) method enables/disables the error, alert, and confirmation dialogs.Are there any guiding principles to avoid deadlocks in the application that uses JExplorer?Don't call the WebBrowser.waitReady() method from Swing or OLE message loop thread.If I work with JExplorer through COM interfaces (native peer objects), I get ComException: COM object method returns error code: 0x80004005; E_FAIL. What's wrong?You should work with peer objects in the OLE message loop of the browser. See the chapter " Working with Native Peers and Avoiding Thread Issues" inside JExplorer Programmer's Guide. Otherwise, please refer to the corresponding interface's documentation in MSDN to get know method specific meaning of the error code.When the browser component is visible all of my menus and tooltips seem to show under the browser panel. Can this be fixed?To solve this problem, just add the following code to appropriate place in your application:static { JPopupMenu.setDefaultLightWeightPopupEnabled(false); I get the following error: ciceroUIWNDFRAME: javaw.exe - apllication error[new]This error is not caused by JNIWrapper, but rather by Microsoft Office's Speech and Handwriting Recognition. In order to continue using JNIWrapper, you will need to disable this Microsoft feature. To disable the Speech and Handwriting Recognition:
|
Documentation >