Catch weird sporadic error that is occasionally thrown when label layout

results from the initial call to pack() on a Frame when an application
first starts up.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@852 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2002-09-25 08:42:00 +00:00
parent 64355cce3c
commit 412d26b2d4
@@ -1,5 +1,5 @@
// //
// $Id: Label.java,v 1.19 2002/09/23 21:19:06 shaper Exp $ // $Id: Label.java,v 1.20 2002/09/25 08:42:00 mdb Exp $
// //
// samskivert library - useful routines for java programs // samskivert library - useful routines for java programs
// Copyright (C) 2002 Michael Bayne // Copyright (C) 2002 Michael Bayne
@@ -303,10 +303,11 @@ public class Label implements SwingConstants, LabelStyleConstants
{ {
// start with a size of zero // start with a size of zero
double width = 0, height = 0; double width = 0, height = 0;
// obtain our new dimensions by using a line break iterator to lay
// out our text one line at a time
ArrayList layouts = new ArrayList(); ArrayList layouts = new ArrayList();
try {
// obtain our new dimensions by using a line break iterator to
// lay out our text one line at a time
TextLayout layout; TextLayout layout;
int lastposition = _text.length(); int lastposition = _text.length();
while ((layout = measurer.nextLayout( while ((layout = measurer.nextLayout(
@@ -327,6 +328,12 @@ public class Label implements SwingConstants, LabelStyleConstants
return null; return null;
} }
} catch (Throwable t) {
Log.warning("Label layout failed [text=" + _text +
", t=" + t + "].");
Log.logStackTrace(t);
}
return layouts; return layouts;
} }