Canvas on Ubuntu 14 not working? [message #1399921] |
Sun, 13 July 2014 07:30  |
Eclipse User |
|
|
|
Hi,
Iam using SWT Canvas to create custom widgets.
It all works fine on Windows Client, but if I start the Eclipse RCP based application on Ubuntu 14, the canvas just looks gray.
I attached to screenshots, how it looks on Ubuntu (linux.png) and how it should look (windows.png).
The widget class is quite straight forward:
public class ListEntry extends Composite{
private final Canvas canvas;
...
public ListEntry(Composite parent, int height, int style) {
super(parent, style);
setBackground(parent.getBackground());
setLayout(new FillLayout());
canvas = new Canvas(this, SWT.NO_BACKGROUND);
canvas.setBackground(parent.getBackground());
canvas.addPaintListener(new StatusPaintListener());
}
...
private class StatusPaintListener implements PaintListener {
@Override
public void paintControl(PaintEvent e) {
Image image = new Image(Display.getCurrent(), canvas.getBounds());
GC gcImage = new GC(image);
//Drawing stuff
...
// Draw the offscreen buffer to the screen
e.gc.drawImage(image, 0, 0);
image.dispose();
gcImage.dispose();
e.gc.dispose();
}
}
If you need the complete source code, just tell me.
Is there any common problem with SWT canvas on Ubuntu/Linux?
FYI
I am using Oracle Java 8.
Thanks for your help and greetings from Germany
Simon
Attachment: linux.PNG
(Size: 2.18KB, Downloaded 199 times)
Attachment: windows.PNG
(Size: 1.83KB, Downloaded 192 times)
|
|
|
|
|
Re: Canvas on Ubuntu 14 not working? [message #1403049 is a reply to message #1403037] |
Sun, 20 July 2014 15:43  |
Eclipse User |
|
|
|
Still the same problem on Eclipse 4.4.
But I think I know the reason:
The constructor of my self made SWT widget class looks like this:
public class ListEntry extends Composite {
...
public ListEntry(Composite parent, int height, int style) {
super(parent, style);
setBackground(parent.getBackground());
...
}
I am calling the constructor with SWT.CENTER flag:
ListEntry en = new ListEntry(listComposite, height, SWT.CENTER);
If I change the flag to SWT.NONE, everything works fine:
ListEntry en = new ListEntry(listComposite, height, SWT.NONE);
Probably the Composite doesnt expect the SWT.CENTER flag and behaves strange on a Linux system if someone uses this flag?
Iam not really sure if its my fault (and I shouldnt use SWT.CENTER as a flag for SWT Composite) or weather there is something wrong with the SWT Composite implemtation.
Thanks
Simon
|
|
|
Powered by
FUDForum. Page generated in 0.04828 seconds