I am subclassing the Canvas in SWT, and calling pack() inside of the constructor,
the Canvas’ size is computed as 64×64.
There is no Style or layout inside of my class.
- How is the size computed at this here?
- How can I change the size of my class?
this.setSize()doesn’t work.
public MyClass(Composite parent, int style) {
super(parent, SWT.NONE);
this.setBackground(getDisplay().getSystemColor(SWT.COLOR_YELLOW));
this.computeSize(1000, 1000, true);
this.pack();
Point s = this.getSize();
System.out.println(s.x); //prints 64
}
You don’t give yourself the size : it is given by the layout of the component using your MyClass.
So your canvas should be ready to handle any size.