Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] Drag and Drop Background problem in Linux

Im having a problem in which i have a background image and a drag source. When i drag the source all my background images disappear as well as any widget backgrounds that have been inherited from their parent composite. This only happens on Linux. Here is a small snippet that recreates the problem. It also happens if i use a GC to place the image on the composite. Any help would be greatly appreciated.


import java.io.InputStream;

import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DragSource;
import org.eclipse.swt.dnd.DragSourceAdapter;
import org.eclipse.swt.dnd.DragSourceEvent;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;


public class Test {

public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setText("Test");
shell.setLayout(new RowLayout(SWT.VERTICAL));
shell.setSize(200,200);

Image image = new Image(display,"./mainico.png");

Composite c = new Composite(shell,SWT.NONE);
c.setBackgroundImage(image);

shell.open();

DragSource thisDS = new DragSource(c, DND.DROP_MOVE);
thisDS.setTransfer(new Transfer[] {TextTransfer.getInstance()});
thisDS.addDragListener(new DragSourceAdapter() {

public void dragSetData(DragSourceEvent event) {

}
});

while(!shell.isDisposed()) {
if(!display.readAndDispatch()) display.sleep();
}
image.dispose();
display.dispose();
}

}


Back to the top