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:Error in running Schemaeditor
Next Topic:GEF printing problem
Goto Forum:
  


Current Time: Thu Apr 25 23:19:09 GMT 2024

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

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

Back to the top