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