Automatically lay out our label if it has not already been.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3349 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2005-02-14 03:01:28 +00:00
parent 99d382fdbf
commit 7cf98ba971
@@ -1,5 +1,5 @@
//
// $Id: LabelSprite.java,v 1.6 2004/08/27 02:12:41 mdb Exp $
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -27,9 +27,10 @@ import java.awt.Graphics2D;
import com.samskivert.swing.Label;
/**
* A sprite that uses a label to render itself. Assumes that the label
* has been previously laid out (see {@link Label#layout}). The label
* should not be altered after the sprite is created.
* A sprite that uses a label to render itself. If the label has not been
* previously laid out (see {@link Label#layout}) it will be done when the
* sprite is added to a media panel. The label should not be altered
* after the sprite is created.
*/
public class LabelSprite extends Sprite
{
@@ -55,6 +56,11 @@ public class LabelSprite extends Sprite
{
super.init();
// if our label is not yet laid out, do the deed
if (!_label.isLaidOut()) {
_label.layout(_mgr.getMediaPanel());
}
// size the bounds to fit our label
Dimension size = _label.getSize();
_bounds.width = size.width;