Added centerComponent().
git-svn-id: https://samskivert.googlecode.com/svn/trunk@737 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -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
|
// samskivert library - useful routines for java programs
|
||||||
// Copyright (C) 2001 Michael Bayne
|
// Copyright (C) 2001 Michael Bayne
|
||||||
@@ -41,6 +41,16 @@ public class SwingUtil
|
|||||||
width, height);
|
width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Centers component <code>b</code> within component <code>a</code>.
|
||||||
|
*/
|
||||||
|
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
|
* Draw a string centered within a rectangle. The string is drawn
|
||||||
* using the graphics context's current font and color.
|
* using the graphics context's current font and color.
|
||||||
|
|||||||
Reference in New Issue
Block a user