diff options
Diffstat (limited to 'libjava/classpath/javax/swing/JViewport.java')
-rw-r--r-- | libjava/classpath/javax/swing/JViewport.java | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/libjava/classpath/javax/swing/JViewport.java b/libjava/classpath/javax/swing/JViewport.java index 5f20f0aa60a..debb5742e2c 100644 --- a/libjava/classpath/javax/swing/JViewport.java +++ b/libjava/classpath/javax/swing/JViewport.java @@ -38,6 +38,8 @@ exception statement from your version. */ package javax.swing; +import gnu.classpath.SystemProperties; + import java.awt.Component; import java.awt.Dimension; import java.awt.Graphics; @@ -163,7 +165,13 @@ public class JViewport extends JComponent implements Accessible public static final int BACKINGSTORE_SCROLL_MODE = 2; private static final long serialVersionUID = -6925142919680527970L; - + + /** + * The default scrollmode to be used by all JViewports as determined by + * the system property gnu.javax.swing.JViewport.scrollMode. + */ + private static final int defaultScrollMode; + protected boolean scrollUnderway; protected boolean isViewSizeSet; @@ -243,21 +251,26 @@ public class JViewport extends JComponent implements Accessible */ boolean sizeChanged = true; - public JViewport() + /** + * Initializes the default setting for the scrollMode property. + */ + static { - setOpaque(true); String scrollModeProp = - System.getProperty("gnu.javax.swing.JViewport.scrollMode", + SystemProperties.getProperty("gnu.javax.swing.JViewport.scrollMode", "BLIT"); - int myScrollMode; if (scrollModeProp.equalsIgnoreCase("simple")) - myScrollMode = SIMPLE_SCROLL_MODE; + defaultScrollMode = SIMPLE_SCROLL_MODE; else if (scrollModeProp.equalsIgnoreCase("backingstore")) - myScrollMode = BACKINGSTORE_SCROLL_MODE; + defaultScrollMode = BACKINGSTORE_SCROLL_MODE; else - myScrollMode = BLIT_SCROLL_MODE; - setScrollMode(myScrollMode); + defaultScrollMode = BLIT_SCROLL_MODE; + } + public JViewport() + { + setOpaque(true); + setScrollMode(defaultScrollMode); updateUI(); setLayout(createLayoutManager()); lastPaintPosition = new Point(); @@ -410,8 +423,9 @@ public class JViewport extends JComponent implements Accessible public void setView(Component v) { - if (viewListener != null) - getView().removeComponentListener(viewListener); + Component currView = getView(); + if (viewListener != null && currView != null) + currView.removeComponentListener(viewListener); if (v != null) { @@ -772,6 +786,9 @@ public class JViewport extends JComponent implements Accessible */ void paintSimple(Graphics g) { + // We need to call this to properly clear the background. + paintComponent(g); + Point pos = getViewPosition(); Component view = getView(); boolean translated = false; |