SWT Canvas randomly expanding composite [message #847850] |
Tue, 17 April 2012 18:10 |
abadamcd1 abadamcd1 Messages: 40 Registered: December 2011 |
Member |
|
|
So I'm putting a text label and a canvas inside of a composite. In the canvas I want to draw a 20x20 circle.
What's weird is that every time I add the canvas to the composite wrapper, it expands the size of the composite vertically in an odd manner like so:
Why does it make it so tall?
When I remove the canvas, the composite shrinks appropriately.
public StationIndicator(String displayTxt, Composite parent){
this(parent);
wrapper = new Composite(parent, SWT.NONE);
wrapper.setLayout(new FillLayout() );
canvas = new Canvas(wrapper, SWT.NONE);
canvas.setBackground(parentz.getDisplay().getSystemColor(SWT.COLOR_GRAY));
label = new Label(wrapper, SWT.NONE);
label.setText(displayTxt);
currColor = parentz.getDisplay().getSystemColor(SWT.COLOR_GRAY);
canvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
//Rectangle clientArea = canvas.getClientArea();
e.gc.setAntialias(SWT.ON);
e.gc.setBackground(parentz.getDisplay().getSystemColor(SWT.COLOR_BLACK));
e.gc.fillOval(0,0,20,20);
e.gc.setBackground(currColor);
e.gc.fillOval(2,2,16,16);
}
});
}
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04267 seconds