[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.rcp] How to locate a draw2d object in viewpart automatically
|
Hello,
I am using some draw2d labels in a viewer of my rcp application and want to
locate one label in the middle of the viewer at the time of initiation.I
have tried to use getSize method of the composite object which i get from
createPartcontrol, but it didn't work.
I am using the following code in createPartControl of my viewer.
Canvas canvas = new Canvas(parent,SWT.NONE);
canvas.setSize(parent.getSize());
LightweightSystem lws = new LightweightSystem(canvas);
Panel parentFigure = new Panel();
parentFigure.setLayoutManager(new XYLayout());
lws.setContents(parentFigure);
Label label = new Label("test");
parentFigure.add(label);
parentFigure.setConstraint(label,new
Rectangle(parent.getSize().x/2,parent.getSize().y/2,-1,-1));
BestRegards
Ning