-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
1.2.0
-
x86
-
windows_nt
Name: el35337 Date: 09/17/98
1) Run the provided program, it's a JViewport with
a simple component view as it's view. Try pressing the
'scroll to last cell' button and see that although
it does scroll correctly it does not redraw the
newly shown part of the view correctly. (paint isn't
even called). Also notice that if you repeatedly
press the scroll to last cell button the set position
call is getting more and more innacurate. Also notice
that pressing the scroll to first cell button has
no effect whatsoever on the position and no set location
call is made to the view. The scrolling bugs can be
tracked down to the scrollRectToVisible method and it's
helper postionAdjustment method, which returns invalid
results due to ignoring the current position of the
view. The paiting problems I don't know where they
stem from, though I suspect they might be related
to the optimization going on in JComponent and the
JViewport only having one child.
2) Here goes:
import com.sun.java.swing.JViewport;
import com.sun.java.swing.JButton;
import com.sun.java.swing.JComponent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Rectangle;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Frame;
import java.awt.Point;
public class ViewportTest extends JComponent{
public static void main(String argv[]){
Frame f = new Frame();
f.setSize(300,400);
final JViewport viewport = new JViewport();
viewport.setBackingStoreEnabled(false);
final ViewportTest view = new ViewportTest();
view.setSize(300,600);
viewport.setView(view);
f.add(viewport,"Center");
JButton firstCell = new JButton("MoveToFirstCell");
firstCell.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
viewport.scrollRectToVisible(new Rectangle(0,0,300,100));
}
});
JButton lastCell = new JButton("MoveToLastCell");
lastCell.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
viewport.scrollRectToVisible(new Rectangle(0,500,300,100));
}
});
f.add(firstCell,"North");
f.add(lastCell,"South");
f.setVisible(true);
}
public void setLocation(int x, int y){
System.out.println("SetLocation: " + x + "," + y);
super.setLocation(x,y);
repaint();
}
public void paint(Graphics g){
System.out.println("Clip: " + g.getClip());
g.setColor(Color.white);
g.fillRect(0,0,300,600);
g.setColor(Color.black);
for(int i=0; i<6; i++){
g.drawRect(0,i*100,300,100);
g.drawString("Rect " + i,10,i*100+10);
}
}
}
3) NA..
4) NA..
5) I'm running 1.2 beta 4.1 (FCS release)
(Review ID: 39016)
======================================================================