简体   繁体   English

WindowBuilder设计模式没有显示我的Widget的视觉特征

[英]WindowBuilder design-mode not showing up visual characteristics of my Widget

I've implemented my own widget (extending Canvas ), that has as distinct characteristic the fact that it's all black. 我已经实现了我自己的小部件(扩展Canvas ),它具有鲜明的特征,即全黑。

When adding my canvas to a Shell in design-mode in WindowBuilder, it looks just like a regular canvas, although when in execution-mode everything shows up just alright. 在WindowBuilder中以设计模式将我的画布添加到Shell时,它看起来就像一个常规画布,虽然在执行模式下一切都显示正常。

Is there anything I'm missing, or is this an inherent limitation on the part of WindowBuilder? 我有什么遗漏,或者这是WindowBuilder的固有限制吗?

Here's the code I'm using, just in case: 这是我正在使用的代码,以防万一:

public class MyCanvas extends Canvas {
    public MyCanvas(Composite parent, int style) {
        super(parent, style);
        setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
        addPaintListener(new PaintListenerEx());
    }

    private class PaintListenerEx implements PaintListener {
        @Override
        public void paintControl(PaintEvent e) {
            e.gc.fillRectangle(MyCanvas.this.getBounds());
            e.gc.dispose();
        }
    }
}

I believe that WindowBuilder is not calling the constructor you are trying to use to initilize your Canvas . 我相信WindowBuilder没有调用你试图用来初始化你的Canvas的构造函数。 WindowBuilder uses some known entry points per framework (like SWT) but sometimes it fails to find one even if you are using the right signature. WindowBuilder使用每个框架的一些已知入口点(如SWT),但有时即使您使用正确的签名也无法找到它。

If you want to specify an entry point for WindowBuilder you can use this: 如果要为WindowBuilder指定入口点,可以使用:

 /**
  * @wbp.parser.entryPoint
  */

to make WindowBuilder start from there but it is not guaranteed to work. 使WindowBuilder从那里开始,但不能保证工作。

There's also the case where you need to specify the default constructor of a specific graphic element. 还有一种情况需要指定特定图形元素的默认构造函数。

 /**
  * @wbp.parser.constructor
  */

In my particular case entryPoint didn't work and this was the solution. 在我的特殊情况下, entryPoint不起作用,这就是解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM