简体   繁体   中英

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.

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.

Is there anything I'm missing, or is this an inherent limitation on the part of 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 uses some known entry points per framework (like SWT) but sometimes it fails to find one even if you are using the right signature.

If you want to specify an entry point for WindowBuilder you can use this:

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

to make WindowBuilder start from there but it is not guaranteed to work.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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