[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

JScrollPane autoscroll?

Posted on 2004-04-19
4
Medium Priority
?
2,691 Views
Last Modified: 2008-02-20
Question 1:
I put a JTable into a JScrollPane and would like to ensure the JTable always scrolled to the BOTTOM automatically.How should I code this?

Question 2:
Besides this, I have a similar porblem but instead a JTable, I am putting a custom line graph component that extends JPanel. How could I ensure that the graph always scrolled to the RIGHT automatically.


0
Comment
Question by:b612_forever
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 10864931
1. table.scrollRectToVisible(table.getCellRect(table.getRowCount(), 0, false));

2. Similar approach, passing the regoin of the panel you want visible.


0
 
LVL 1

Author Comment

by:b612_forever
ID: 10865551
I always think that the solution should come from the JScrollPane so I can't find the solution.

Thank you very much for your help.
0
 
LVL 92

Expert Comment

by:objects
ID: 10865568
0
 
LVL 1

Expert Comment

by:HammanSamuel
ID: 20099663
Here's a method you could use (a solution using JScrollPane):
--------------------
public void autoScroll(JScrollPane sPane){
        sPane.validate();
        JScrollBar vScroll = sPane.getVerticalScrollBar();
        vScroll.setValue(vScroll.getMaximum());
}
-------------------
You can include this method in your class and call it by passing the scroll pane object that is holding your table. Call this method to the event in the same place as where the table contents are initialized.
0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question