Bug 160691

Summary: RFE: Please add a snipplet about SWT_AWT.new_Shell
Product: [Eclipse Project] Platform Reporter: Jan Kümmel <eclipse-bugs>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: chrriis, ericwill, ndeverge, steve_northover
Version: 3.3   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Jan Kümmel CLA 2006-10-12 11:32:29 EDT
I am unable to embed swt widgets to a swing component using SWT_AWT.new_Shell on linux/gtk2 while the same code seems to run on win32.

Please add a snipplet which shows how to embed swt into awt correctly.

Such a snipplet would make it possible to see whether there a bug in swt or I am simply too stupid to use it right ;-)
Comment 1 Nico CLA 2006-10-17 09:24:30 EDT
I have a similar problem, the SWT Widgets are not displayed in my AWT Frame.
Here is the code :
public static void main(String[] args) {
        java.awt.Frame frame = new java.awt.Frame("AWT Frame");
        java.awt.Button button = new java.awt.Button("AWT Button");
        frame.add(button, java.awt.BorderLayout.NORTH);
        java.awt.Canvas canvas = new java.awt.Canvas();
        frame.add(canvas, java.awt.BorderLayout.CENTER);

        frame.addNotify();
       
        Display display = new Display();
        Shell shell = SWT_AWT.new_Shell(display, canvas);
        shell.setLayout(new FillLayout());
        Button swtButton = new Button(shell, SWT.PUSH);
        swtButton.setText("SWT Button");
       
        frame.setBounds(20, 20, 300, 300);
        shell.layout();
        frame.setVisible(true);
       
        while (!shell.isDisposed()) {
                if (!display.readAndDispatch()) display.sleep();
        }
}
Comment 2 Christopher Deckers CLA 2008-04-04 08:08:49 EDT
> I am unable to embed swt widgets to a swing component using SWT_AWT.new_Shell
on linux/gtk2 while the same code seems to run on win32.

Maybe it is because you are using Java 5 or that you are not setting the "sun.awt.xembedserver" system property to true, as discussed in bug 161911.
Note that about the Linux Java 5 support, there is a bug in Sun's bug database you could vote for: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6671386

+1 for a snippet that shows the new_Shell functionality though.
Comment 3 Eric Williams CLA 2016-08-18 16:19:29 EDT
Tossing back into the pool to see if anyone wants to work on this.