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

  • SEARCH
  • Home
  • 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 7090011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:59:32+00:00 2026-05-28T07:59:32+00:00

I am dealing with JEditorPane to display HTML documents and I created a button

  • 0

I am dealing with JEditorPane to display HTML documents and I created a button which scroll me to next view port every time I click it, “as if I am turning a page of a book”.

However, sometimes I see a part of a line at the top of the view port, so is there any way to force JScrollBar to scroll to ahead of a line?

I tried setBlockIncrement() member method but it didn’t work at all.

Here you are my best attempt:

//get the visible rectangle as well as the most bottom right point. 
Rectangle rec = jEditorPane1.getVisibleRect();
Point pt = new Point((int)rec.getX() +(int)rec.getWidth(),(int)rec.getY() +      (int)rec.getHeight());
// get the offset of the most bottom right point 
int off = jEditorPane1.viewToModel(pt);
try {
//get next viewable rectangle and scroll to it 
rec = jEditorPane1.modelToView(off+100);
rec.height = jEditorPane1.getVisibleRect().height;
jEditorPane1.scrollRectToVisible(rec);
} catch (BadLocationException ex) {
Logger.getLogger(NewJFrame2.class.getName()).log(Level.SEVERE, null, ex);
}
  • 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-05-28T07:59:33+00:00Added an answer on May 28, 2026 at 7:59 am

    Guess you have a position in the Document you want to show. You can get visible rect of the position using modelToView() method. and use the y position to set your viewport. E.g. use scrollRectToVisible passing the y and viewport height in the rectangle parameter.

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

Sidebar

Related Questions

I dealing with the next problem, I have a asp.net web project in which
Dealing with Java - which the option you prefer in the most cases -
When dealing with big databases, which performs better: IN or OR in the SQL
I've been dealing with this problem for quite some time. What I am trying
I'm dealing with a null pointer exception for which I have a stack trace.
When dealing with any framework with which you are not 100% familiar, I've found
I'm dealing with a list of games and wanted to find out which player
Dealing with an employee that went over my head
When dealing with small projects, what do you feel is the break even point
When dealing with a series of numbers, and wanting to use hash results for

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.