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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user