Thanks. Its works using the SWT AWT Bridge embeding the canvas in an SWT shell.
Screenshot
http://www.screencast.com/t/l7lUSi42
There's little issue with both the CanvasContainerTest and this one. rendering isn't started until the mouse is click in the canvas area . The requestFocus() method is called in the CanvasGameContainer contructor but has no effect until requestFocus() is called after container.start().
Code:
public static void main(String[] argv) {
try {
CanvasGameContainer container = new CanvasGameContainer(new CompositeContainerTest());
shell = new Shell();
shell.setSize(500,500);
display = shell.getDisplay();
shell.setLayout(new GridLayout());
shell.setText("CompositeContainerTest");
final Menu mBar = new Menu(shell, SWT.BAR);
shell.setMenuBar(mBar);
final MenuItem fileItem = new MenuItem(mBar, SWT.CASCADE);
fileItem.setText("File");
final Menu fileMenu = new Menu(fileItem);
fileItem.setMenu(fileMenu);
for (int i = 0; i < 5; i++) {
final MenuItem importItem = new MenuItem(fileMenu, SWT.NONE);
importItem.setText("Item " + i);
}
Composite containerComp = new Composite(shell, SWT.EMBEDDED);
containerComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
java.awt.Frame containerFrame = SWT_AWT.new_Frame(containerComp);
containerFrame.add(container);
container.getContainer().setAlwaysRender(true);
container.requestFocus();
container.start();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
shell.dispose();
} catch (Exception e) {
e.printStackTrace();
}
}