The realization of the Jscrollpanel scroll bar automatic sliding to the bottom part

Source: Internet
Author: User
Tags rowcount

    1. When Jscrollpanel is used with jtable, there are two ways to add the following code to the listener, which is always at the bottom when you add a row to the table:

      Method 1 (This method works fine):

int rowCount = Tbllogstate.getrowcount ();    Tbllogstate.getselectionmodel (). setSelectionInterval (RowCount-1, rowCount-1);    Rectangle rect = tbllogstate.getcellrect (rowCount-1, 0, true);    Tbllogstate.updateui (); Tbllogstate.scrollrecttovisible (rect);

Method 2 (The method will appear when the new line interface cannot be refreshed):

Jscrollbar ScrollBar = Sptablestate.getverticalscrollbar (); Scrollbar.setvalue (Scrollbar.getmaximum ());

2. Jscrollpanel when used with JTextArea.

Method (pending test)

int height=10;    Point P = new Point ();    P.setlocation (0,this.jtextarea1.getlinecount () *height); This.jScrollPane1.getViewport (). Setviewposition (P);

Reference Document: http://blog.csdn.net/dancen/article/details/7379847

The realization of the Jscrollpanel scroll bar automatic sliding to the bottom part

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.