Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » calling getPreferredSize() to a label
calling getPreferredSize() to a label [message #235799] Fri, 15 June 2007 19:41
Eclipse UserFriend
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)
....
Previous Topic:Can Resource Navigator display files with specific extensions
Next Topic:Problem in product
Goto Forum:
  


Current Time: Fri Aug 19 11:26:16 GMT 2022

Powered by FUDForum. Page generated in 0.01531 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top