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:
@@ -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;
|
package com.samskivert.swing;
|
||||||
|
|
||||||
@@ -12,6 +12,8 @@ import javax.swing.JPanel;
|
|||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
|
|
||||||
|
import com.samskivert.swing.util.SwingUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A panel that contains a button which will collapse the rest of the content.
|
* 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);
|
_content.setVisible(true);
|
||||||
_trigger.setIcon(_upIcon);
|
_trigger.setIcon(_upIcon);
|
||||||
}
|
}
|
||||||
revalidate();
|
SwingUtil.refresh(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The button that triggers collapsion. */
|
/** 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;
|
package com.samskivert.swing;
|
||||||
|
|
||||||
@@ -22,6 +22,7 @@ import javax.swing.event.ListDataEvent;
|
|||||||
import javax.swing.event.ListDataListener;
|
import javax.swing.event.ListDataListener;
|
||||||
|
|
||||||
import com.samskivert.Log;
|
import com.samskivert.Log;
|
||||||
|
import com.samskivert.swing.util.SwingUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to display a horizontal or vertical array of buttons, out of which
|
* 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
|
// remove the buttons in the specified interval
|
||||||
int start = e.getIndex0(), count = e.getIndex1() - start + 1;
|
int start = e.getIndex0(), count = e.getIndex1() - start + 1;
|
||||||
removeButtons(start, count);
|
removeButtons(start, count);
|
||||||
revalidate();
|
SwingUtil.refresh(this);
|
||||||
repaint();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
@@ -312,8 +312,7 @@ public class ComboButtonBox extends JPanel
|
|||||||
add(ibut, i);
|
add(ibut, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
revalidate();
|
SwingUtil.refresh(this);
|
||||||
repaint();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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
|
// samskivert library - useful routines for java programs
|
||||||
// Copyright (C) 2001 Michael Bayne
|
// Copyright (C) 2001 Michael Bayne
|
||||||
@@ -40,7 +40,7 @@ import java.util.Collection;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JComponent;
|
||||||
|
|
||||||
import javax.swing.text.AbstractDocument;
|
import javax.swing.text.AbstractDocument;
|
||||||
import javax.swing.text.AttributeSet;
|
import javax.swing.text.AttributeSet;
|
||||||
@@ -478,14 +478,15 @@ public class SwingUtil
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refreshes the supplied panel display. This should be called after
|
* Refreshes the supplied {@link JComponent} to effect a call to
|
||||||
* adding components to or removing components from the panel since
|
* {@link JComponent#revalidate} and {@link JComponent#repaint}, which
|
||||||
* Swing doesn't automatically properly invalidate things for
|
* is frequently necessary in cases such as adding components to or
|
||||||
* subsequent re-rendering.
|
* 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();
|
c.revalidate();
|
||||||
panel.repaint();
|
c.repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user