jdk/src/share/classes/javax/swing/JViewport.java
changeset 23280 df31f522531f
parent 22574 7f8ce0c8c20a
child 23328 4c53a6ebc779
equal deleted inserted replaced
23279:16c1ddb7b66a 23280:df31f522531f
    23  * questions.
    23  * questions.
    24  */
    24  */
    25 
    25 
    26 package javax.swing;
    26 package javax.swing;
    27 
    27 
    28 import sun.swing.JLightweightFrame;
       
    29 
       
    30 import java.awt.*;
    28 import java.awt.*;
    31 import java.awt.event.*;
    29 import java.awt.event.*;
    32 import java.awt.peer.ComponentPeer;
    30 import java.awt.peer.ComponentPeer;
    33 import java.beans.Transient;
    31 import java.beans.Transient;
    34 import javax.swing.plaf.ViewportUI;
    32 import javax.swing.plaf.ViewportUI;
    35 
    33 
    36 import javax.swing.event.*;
    34 import javax.swing.event.*;
    37 import javax.swing.border.*;
    35 import javax.swing.border.*;
    38 import javax.accessibility.*;
    36 import javax.accessibility.*;
    39 
    37 
    40 
       
    41 import java.io.Serializable;
    38 import java.io.Serializable;
    42 
       
    43 
    39 
    44 /**
    40 /**
    45  * The "viewport" or "porthole" through which you see the underlying
    41  * The "viewport" or "porthole" through which you see the underlying
    46  * information. When you scroll, what moves is the viewport. It is like
    42  * information. When you scroll, what moves is the viewport. It is like
    47  * peering through a camera's viewfinder. Moving the viewfinder upwards
    43  * peering through a camera's viewfinder. Moving the viewfinder upwards
   362     public void remove(Component child) {
   358     public void remove(Component child) {
   363         child.removeComponentListener(viewListener);
   359         child.removeComponentListener(viewListener);
   364         super.remove(child);
   360         super.remove(child);
   365     }
   361     }
   366 
   362 
   367     @Override
       
   368     public void addNotify() {
       
   369         super.addNotify();
       
   370         // JLightweightFrame does not support BLIT_SCROLL_MODE, so it should be replaced
       
   371         Window rootWindow = SwingUtilities.getWindowAncestor(this);
       
   372         if (rootWindow instanceof JLightweightFrame
       
   373                 && getScrollMode() == BLIT_SCROLL_MODE) {
       
   374             setScrollMode(BACKINGSTORE_SCROLL_MODE);
       
   375         }
       
   376     }
       
   377 
       
   378 
       
   379     /**
   363     /**
   380      * Scrolls the view so that <code>Rectangle</code>
   364      * Scrolls the view so that <code>Rectangle</code>
   381      * within the view becomes visible.
   365      * within the view becomes visible.
   382      * <p>
   366      * <p>
   383      * This attempts to validate the view before scrolling if the
   367      * This attempts to validate the view before scrolling if the
  1107                     rm.beginPaint();
  1091                     rm.beginPaint();
  1108                     try {
  1092                     try {
  1109                         Graphics g = JComponent.safelyGetGraphics(this);
  1093                         Graphics g = JComponent.safelyGetGraphics(this);
  1110                         flushViewDirtyRegion(g, dirty);
  1094                         flushViewDirtyRegion(g, dirty);
  1111                         view.setLocation(newX, newY);
  1095                         view.setLocation(newX, newY);
  1112                         g.setClip(0,0,getWidth(), Math.min(getHeight(),
  1096                         Rectangle r = new Rectangle(
  1113                                                            jview.getHeight()));
  1097                             0, 0, getWidth(), Math.min(getHeight(), jview.getHeight()));
       
  1098                         g.setClip(r);
  1114                         // Repaint the complete component if the blit succeeded
  1099                         // Repaint the complete component if the blit succeeded
  1115                         // and needsRepaintAfterBlit returns true.
  1100                         // and needsRepaintAfterBlit returns true.
  1116                         repaintAll = (windowBlitPaint(g) &&
  1101                         repaintAll = (windowBlitPaint(g) &&
  1117                                       needsRepaintAfterBlit());
  1102                                       needsRepaintAfterBlit());
  1118                         g.dispose();
  1103                         g.dispose();
       
  1104                         rm.notifyRepaintPerformed(this, r.x, r.y, r.width, r.height);
  1119                         rm.markCompletelyClean((JComponent)getParent());
  1105                         rm.markCompletelyClean((JComponent)getParent());
  1120                         rm.markCompletelyClean(this);
  1106                         rm.markCompletelyClean(this);
  1121                         rm.markCompletelyClean(jview);
  1107                         rm.markCompletelyClean(jview);
  1122                     } finally {
  1108                     } finally {
  1123                         rm.endPaint();
  1109                         rm.endPaint();