Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Canvas on Ubuntu 14 not working?
Canvas on Ubuntu 14 not working? [message #1399921] Sun, 13 July 2014 11:30 Go to next message
Simon Mising name is currently offline Simon Mising nameFriend
Messages: 12
Registered: December 2011
Junior Member
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 174 times)
  • Attachment: windows.PNG
    (Size: 1.83KB, Downloaded 171 times)
Re: Canvas on Ubuntu 14 not working? [message #1400414 is a reply to message #1399921] Mon, 14 July 2014 06:59 Go to previous messageGo to next message
Niraj Modi is currently offline Niraj ModiFriend
Messages: 48
Registered: November 2013
Member
Hi Simon,
On Ubuntu 14, GTK 3.10 is the default and few issues has been taken care of in the latest Eclipse 4.4 release.
Suggest you to try out the latest Eclipse/SWT release, which can be downloaded from:
http://download.eclipse.org/eclipse/downloads/drops4/R-4.4-201406061215/

If you still face problem, please revert with a complete code snippet demonstrating the problem. Thanks!
Re: Canvas on Ubuntu 14 not working? [message #1403037 is a reply to message #1400414] Sun, 20 July 2014 15:14 Go to previous messageGo to next message
Simon Mising name is currently offline Simon Mising nameFriend
Messages: 12
Registered: December 2011
Junior Member
Thanks, I will try it.
Re: Canvas on Ubuntu 14 not working? [message #1403049 is a reply to message #1403037] Sun, 20 July 2014 19:43 Go to previous message
Simon Mising name is currently offline Simon Mising nameFriend
Messages: 12
Registered: December 2011
Junior Member
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
Previous Topic:Why Display.addFilter doesn't works with hotkeys?
Next Topic:Failed to create Ole Client
Goto Forum:
  


Current Time: Fri Mar 29 08:00:36 GMT 2024

Powered by FUDForum. Page generated in 0.02999 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top