I am rendering a webpage and trying to scroll to a location within it. However, the scrolling doesn't work.
This is my code...
import org.lobobrowser.html.*;
import org.lobobrowser.html.gui.HtmlPanel;
import org.lobobrowser.html.parser.*;
import org.lobobrowser.html.test.*;
import org.w3c.dom.*;
import org.xml.sax.*;
public class finall {
Node goTo;
public void show(URL url,Node theFinalNode) throws MalformedURLException, IOException, SAXException {
goTo = theFinalNode;
String uri=url.toString();
URLConnection connection = url.openConnection();
InputStream in = connection.getInputStream();
Reader reader = new InputStreamReader(in);
InputSource is = new InputSourceImpl(reader, uri);
UserAgentContext uAgent=new SimpleUserAgentContext();
final HtmlPanel htmlPanel = new HtmlPanel();
HtmlRendererContext rendererContext = (HtmlRendererContext) new LocalHtmlRendererContext(htmlPanel, uAgent);
DocumentBuilderImpl builder = new DocumentBuilderImpl(uAgent, rendererContext);
Document document = builder.parse(is);
JFrame frame = new JFrame();
frame.getContentPane().add(htmlPanel);
htmlPanel.setDocument(document, rendererContext);
frame.setSize(300, 450);
frame.setVisible(true);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
htmlPanel.scrollTo(goTo);
}
});
}
Could someone please help me understand why the scrolling doesn't work.