We can't just constrain ourselves on our first layout because we may be

laid out again with a different size (for example if we're in a scrolled
pane) and we need to respond to that. So now we re-constrain any time our
dimensions are changed.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@942 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2002-11-22 21:21:32 +00:00
parent 3826db36ca
commit 87ef33ddf8
@@ -1,5 +1,5 @@
// //
// $Id: MultiLineLabel.java,v 1.8 2002/11/12 06:41:29 mdb Exp $ // $Id: MultiLineLabel.java,v 1.9 2002/11/22 21:21:32 mdb Exp $
// //
// samskivert library - useful routines for java programs // samskivert library - useful routines for java programs
// Copyright (C) 2002 Walter Korman // Copyright (C) 2002 Walter Korman
@@ -252,21 +252,24 @@ public class MultiLineLabel extends JComponent
// if we have been configured to relay ourselves out once we know // if we have been configured to relay ourselves out once we know
// our constrained width or height, take care of that here // our constrained width or height, take care of that here
int size;
switch (_constrain) { switch (_constrain) {
case HORIZONTAL: case HORIZONTAL:
size = getWidth();
// sanity check; sometimes labels are laid out with completely // sanity check; sometimes labels are laid out with completely
// invalid dimensions, so we just quietly play along // invalid dimensions, so we just quietly play along
if (getWidth() > 0) { if (size > 0 && size != _constrainedSize) {
_constrain = NONE; _constrainedSize = size;
_label.setTargetWidth(getWidth()); _label.setTargetWidth(size);
revalidate(); revalidate();
} }
break; break;
case VERTICAL: case VERTICAL:
if (getHeight() > 0) { size = getHeight();
_constrain = NONE; if (size > 0 && size != _constrainedSize) {
_label.setTargetHeight(getHeight()); _constrainedSize = size;
_label.setTargetHeight(size);
revalidate(); revalidate();
} }
break; break;
@@ -323,6 +326,10 @@ public class MultiLineLabel extends JComponent
/** Pending constraint adjustments. */ /** Pending constraint adjustments. */
protected int _constrain = NONE; protected int _constrain = NONE;
/** The size to which we constrained ourselves when most recently laid
* out. */
protected int _constrainedSize;
/** Whether to render the label with anti-aliasing. */ /** Whether to render the label with anti-aliasing. */
protected boolean _antialiased; protected boolean _antialiased;