Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4349485

JViewport scrolling dosen't paints properly

XMLWordPrintable

      Jviewport scrolling and painiing problems exists in JDK 1.2.2_05a. This is similar to the bug id# 4174513 (which may have been fixed in jdk 1.2 for Win_NT). This problem exists only on Solaris and works fine on windows.

      The testcase from bug id# 4174513 can be used to simulate the problem:


      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);
                      }
              }
      }

      Another testcase derived from customer's application is available on /net/frsico.eng/export/fujitsu/732846_jviewport. The two files of interest in this testcase are ButtonArray.java and Test.java. To run this test, run java Test and click on Right scroll button or Right page scroll buttons. The buttons should scroll and repaint which dosen't works.

      The behaviour is different in JDk 1.3 Beta but the problem shows up only when you click on button scroll button but works fine for page button scroll button.

            svioletsunw Scott Violet (Inactive)
            rramchansunw Rajesh Ramchandani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: