我正在编写一个基于 Eclipse RCP 的应用程序,并试图在 ViewPart 上绘制一个矩形。但是,即使指定了边界,矩形似乎也占据了整个屏幕。以下是我的代码。
public void createPartControl(Composite parent) {
Shell shell = parent.getShell();
Canvas canvas = new Canvas(parent, SWT.NONE);
LightweightSystem lws = new LightweightSystem(canvas);
RectangleFigure rectangle = new RectangleFigure();
rectangle.setBounds(new Rectangle(0, 0, 10, 10));
rectangle.setBackgroundColor(ColorConstants.green);
lws.setContents(rectangle);
}