-
Bug
-
Resolution: Fixed
-
P4
-
1.2.0, 1.2.2, 1.2.2_05a
-
beta
-
generic, x86, sparc
-
generic, solaris_2.6, windows_nt
Bring up the following test, click on the scroll button and then click it again. Notice that you see row 98 and 99 twice. JViewport.scrollRectToVisible, if passed a bounds greater than the viewport views bounds, scrolls the viewport view such that the viewport does not completely contain the view. scrollRectToVisible should now allow this to happen.
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
public class ScrollRectToVisibleTest {
public static void main(String[] args) {
JFrame frame = new JFrame("test");
final JTable table = new JTable(new TestModel());
JButton scrollButton = new JButton("Scroll");
scrollButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
Rectangle bounds = table.getBounds();
bounds.y = bounds.height + table.getRowHeight();
bounds.height = table.getRowHeight();
System.out.println("scrolling: " + bounds);
table.scrollRectToVisible(bounds);
System.out.println("bounds: " + table.getVisibleRect());
}
});
frame.getContentPane().add(new JScrollPane(table),
BorderLayout.CENTER);
frame.getContentPane().add(scrollButton, BorderLayout.SOUTH);
frame.pack();
frame.show();
}
static class TestModel extends AbstractTableModel {
public String getColumnName(int column) {
return Integer.toString(column);
}
public int getRowCount() {
return 100;
}
public int getColumnCount() {
return 5;
}
public Object getValueAt(int row, int col) {
return row + " x " + col;
}
public boolean isCellEditable(int row, int column) { return false; }
public void setValueAt(Object value, int row, int col) {
}
}
}
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
public class ScrollRectToVisibleTest {
public static void main(String[] args) {
JFrame frame = new JFrame("test");
final JTable table = new JTable(new TestModel());
JButton scrollButton = new JButton("Scroll");
scrollButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
Rectangle bounds = table.getBounds();
bounds.y = bounds.height + table.getRowHeight();
bounds.height = table.getRowHeight();
System.out.println("scrolling: " + bounds);
table.scrollRectToVisible(bounds);
System.out.println("bounds: " + table.getVisibleRect());
}
});
frame.getContentPane().add(new JScrollPane(table),
BorderLayout.CENTER);
frame.getContentPane().add(scrollButton, BorderLayout.SOUTH);
frame.pack();
frame.show();
}
static class TestModel extends AbstractTableModel {
public String getColumnName(int column) {
return Integer.toString(column);
}
public int getRowCount() {
return 100;
}
public int getColumnCount() {
return 5;
}
public Object getValueAt(int row, int col) {
return row + " x " + col;
}
public boolean isCellEditable(int row, int column) { return false; }
public void setValueAt(Object value, int row, int col) {
}
}
}
- duplicates
-
JDK-4232930 REGRESSION: PageDown in JTree in JScrollPane incorrectly changes tree bounds
-
- Closed
-
-
JDK-4349485 JViewport scrolling dosen't paints properly
-
- Closed
-
-
JDK-4259296 Redraw problem with page up/page down for JTree in a JScrollPane
-
- Closed
-
-
JDK-4302327 JViewport.ScrollRectToVisible() calculates incorrect viewpoint
-
- Closed
-