When the content is made visible, also make sure it's scrolled into view.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@1153 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,10 +1,15 @@
|
|||||||
//
|
//
|
||||||
// $Id: CollapsiblePanel.java,v 1.7 2003/01/15 00:17:37 mdb Exp $
|
// $Id: CollapsiblePanel.java,v 1.8 2003/06/26 05:55:47 ray Exp $
|
||||||
|
|
||||||
package com.samskivert.swing;
|
package com.samskivert.swing;
|
||||||
|
|
||||||
|
import java.awt.EventQueue;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.ComponentAdapter;
|
||||||
|
import java.awt.event.ComponentEvent;
|
||||||
|
|
||||||
import javax.swing.AbstractButton;
|
import javax.swing.AbstractButton;
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
@@ -71,6 +76,24 @@ public class CollapsiblePanel extends JPanel
|
|||||||
add(comp);
|
add(comp);
|
||||||
add(_content = content);
|
add(_content = content);
|
||||||
|
|
||||||
|
// When the content is shown, make sure it's scrolled visible
|
||||||
|
_content.addComponentListener(new ComponentAdapter() {
|
||||||
|
public void componentShown (ComponentEvent event)
|
||||||
|
{
|
||||||
|
// we can't do it just yet, the content doesn't know its size
|
||||||
|
EventQueue.invokeLater(new Runnable() {
|
||||||
|
public void run () {
|
||||||
|
// The content is offset a bit from the trigger
|
||||||
|
// but we want the trigger to show up, so we add
|
||||||
|
// in point 0,0
|
||||||
|
Rectangle r = _content.getBounds();
|
||||||
|
r.add(0, 0);
|
||||||
|
scrollRectToVisible(r);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// and start us out not showing
|
// and start us out not showing
|
||||||
setCollapsed(true);
|
setCollapsed(true);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user