diff --git a/projects/samskivert/src/java/com/samskivert/swing/util/SwingUtil.java b/projects/samskivert/src/java/com/samskivert/swing/util/SwingUtil.java index f3d160fc..c54683cd 100644 --- a/projects/samskivert/src/java/com/samskivert/swing/util/SwingUtil.java +++ b/projects/samskivert/src/java/com/samskivert/swing/util/SwingUtil.java @@ -1,5 +1,5 @@ // -// $Id: SwingUtil.java,v 1.6 2002/03/26 19:32:16 mdb Exp $ +// $Id: SwingUtil.java,v 1.7 2002/05/13 17:40:15 shaper Exp $ // // samskivert library - useful routines for java programs // Copyright (C) 2001 Michael Bayne @@ -41,6 +41,16 @@ public class SwingUtil width, height); } + /** + * Centers component b within component a. + */ + public static void centerComponent (Component a, Component b) + { + Dimension asize = a.getSize(), bsize = b.getSize(); + b.setLocation((asize.width - bsize.width) / 2, + (asize.height - bsize.height) / 2); + } + /** * Draw a string centered within a rectangle. The string is drawn * using the graphics context's current font and color.