From e05341f035a9e5fd05e41e4d27779287978d8eba Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 5 Nov 2002 05:51:18 +0000 Subject: [PATCH] When the JViewport scrolls its components, it simply calls setLocation() which results in the component (and every other component in between that component and the Sun) becoming invalid. Unfortunately, it isn't kind enough to also let the RepaintManager know about its jokey business, and so things simply remain invalid until some other joker comes along and invalidates everything on God's green earth (like the JTextField). We hack in a call to revalidate() on our poor unsuspecting scrolled component so that everything will work properly. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1901 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../com/threerings/media/SafeScrollPane.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/java/com/threerings/media/SafeScrollPane.java b/src/java/com/threerings/media/SafeScrollPane.java index ac8727895..0425fbf0f 100644 --- a/src/java/com/threerings/media/SafeScrollPane.java +++ b/src/java/com/threerings/media/SafeScrollPane.java @@ -1,10 +1,12 @@ // -// $Id: SafeScrollPane.java,v 1.4 2002/10/06 20:57:36 mdb Exp $ +// $Id: SafeScrollPane.java,v 1.5 2002/11/05 05:51:18 mdb Exp $ package com.threerings.media; import java.awt.Component; +import java.awt.Point; +import javax.swing.JComponent; import javax.swing.JScrollPane; import javax.swing.JViewport; @@ -24,7 +26,20 @@ public class SafeScrollPane extends JScrollPane protected JViewport createViewport () { - JViewport vp = new JViewport(); + JViewport vp = new JViewport() { + public void setViewPosition (Point p) { + super.setViewPosition(p); + // simple scroll mode results in setViewPosition causing + // our view to become invalid, but nothing ever happens to + // queue up a revalidate for said view, so we have to do + // it here + Component c = getView(); + if (c instanceof JComponent) { + System.out.println("Revalidating " + c); + ((JComponent)c).revalidate(); + } + } + }; vp.setScrollMode(JViewport.SIMPLE_SCROLL_MODE); return vp; }