calling getPreferredSize() to a label [message #235799] |
Fri, 15 June 2007 19:41 |
Eclipse User |
|
|
|
Originally posted by: hoelzel.tcs.ifi.lmu.de
Hello,
I want to call getPreferredSize() to determine the width of a label. But
the call results in a NullPointerException. See the following code snippet
and the error log.
Code Snippet
protected IFigure createFigure() {
Label label = new Label("testlabel");
int widthOfLabel = label.getPreferredSize(30,40).width;
}
ErrorLog:
java.lang.NullPointerException
at org.eclipse.draw2d.FigureUtilities.setFont(FigureUtilities.j ava:369)
at
org.eclipse.draw2d.FigureUtilities.getTextDimension(FigureUt ilities.java:87)
at
org.eclipse.draw2d.FigureUtilities.getTextExtents(FigureUtil ities.java:167)
at org.eclipse.draw2d.Label.getMinimumSize(Label.java:317)
at
de.lmu.ifi.tcs.dataflowdiagram.editparts.FunctionEditPart.cr eateFigure(FunctionEditPart.java:53)
....
|
|
|
Powered by
FUDForum. Page generated in 0.02460 seconds