Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7876939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:14:55+00:00 2026-06-03T03:14:55+00:00

I am rendering a webpage and trying to scroll to a location within it.

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:14:56+00:00Added an answer on June 3, 2026 at 3:14 am

    It looks to me as if the Node that you are passing in to the show method is not in the document being viewed by the HtmlPanel. In your code you build the document using:

    Document document = builder.parse(is);
    

    This will create a new document and a lot of new Nodes associated with it. The parameter theFinalNode will not be part of this document as it was created before the document was created. You will need to extract the Node you want from your new document by calling methods on the document object, or by using something like XPath:

    http://www.roseindia.net/tutorials/xPath/java-xpath.shtml

    Once you have a Node that is actually part of the viewed document then the scrollTo method should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Nothing to do with rendering an individual image on a webpage. Goal is to
Google Chrome 17 introduced a new feature which preloads a webpage to improve rendering
I tried rendering my div images like this horizontally (left-to-right, top-to-bottom). But it's not
I am trying to host an existing win-forms usercontrol in a webpage. I am
This is true for IE 7, 8, and 9. The page http://www.topics2look.com/code-examples/firebug-lite-race-condition/using-remote-firebug-lite-js-file.html loads Firebug
I'm looking at some older code which is rendering some images, animations, etc... for
How can i test webpage/app rendering for slow speed connection?
I have an ASP.NET webpage that is rendering many (~3000) <input type=text> textboxes on
I'm trying to show a jquery mobile webpage on my webview, but I'm having
I'd like to fetch a webpage, just fetching the data (not parsing or rendering

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.