Made SwingUtil.refresh() take a JComponent rather than a JPanel so that we

can make use of it in the most generic circumstances.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@1008 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
shaper
2003-01-11 00:44:53 +00:00
parent 5e57ee8d82
commit aeb225d7ad
3 changed files with 18 additions and 16 deletions
@@ -1,5 +1,5 @@
//
// $Id: CollapsiblePanel.java,v 1.5 2002/11/12 08:18:36 mdb Exp $
// $Id: CollapsiblePanel.java,v 1.6 2003/01/11 00:44:53 shaper Exp $
package com.samskivert.swing;
@@ -12,6 +12,8 @@ import javax.swing.JPanel;
import javax.swing.Icon;
import javax.swing.SwingConstants;
import com.samskivert.swing.util.SwingUtil;
/**
* A panel that contains a button which will collapse the rest of the content.
*/
@@ -132,7 +134,7 @@ public class CollapsiblePanel extends JPanel
_content.setVisible(true);
_trigger.setIcon(_upIcon);
}
revalidate();
SwingUtil.refresh(this);
}
/** The button that triggers collapsion. */
@@ -1,5 +1,5 @@
//
// $Id: ComboButtonBox.java,v 1.3 2002/03/10 20:28:56 mdb Exp $
// $Id: ComboButtonBox.java,v 1.4 2003/01/11 00:44:53 shaper Exp $
package com.samskivert.swing;
@@ -22,6 +22,7 @@ import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener;
import com.samskivert.Log;
import com.samskivert.swing.util.SwingUtil;
/**
* Used to display a horizontal or vertical array of buttons, out of which
@@ -228,8 +229,7 @@ public class ComboButtonBox extends JPanel
// remove the buttons in the specified interval
int start = e.getIndex0(), count = e.getIndex1() - start + 1;
removeButtons(start, count);
revalidate();
repaint();
SwingUtil.refresh(this);
}
// documentation inherited from interface
@@ -312,8 +312,7 @@ public class ComboButtonBox extends JPanel
add(ibut, i);
}
revalidate();
repaint();
SwingUtil.refresh(this);
}
/**
@@ -1,5 +1,5 @@
//
// $Id: SwingUtil.java,v 1.19 2003/01/11 00:40:39 shaper Exp $
// $Id: SwingUtil.java,v 1.20 2003/01/11 00:44:53 shaper Exp $
//
// samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne
@@ -40,7 +40,7 @@ import java.util.Collection;
import java.util.Comparator;
import java.util.Iterator;
import javax.swing.JPanel;
import javax.swing.JComponent;
import javax.swing.text.AbstractDocument;
import javax.swing.text.AttributeSet;
@@ -478,14 +478,15 @@ public class SwingUtil
}
/**
* Refreshes the supplied panel display. This should be called after
* adding components to or removing components from the panel since
* Swing doesn't automatically properly invalidate things for
* subsequent re-rendering.
* Refreshes the supplied {@link JComponent} to effect a call to
* {@link JComponent#revalidate} and {@link JComponent#repaint}, which
* is frequently necessary in cases such as adding components to or
* removing components from a {@link JPanel} since Swing doesn't
* automatically invalidate things for proper re-rendering.
*/
public static void refresh (JPanel panel)
public static void refresh (JComponent c)
{
panel.revalidate();
panel.repaint();
c.revalidate();
c.repaint();
}
}