Embeded AWT MenuBar Into SWT [message #444239] |
Sat, 09 October 2004 23:26  |
Eclipse User |
|
|
|
In order to change the style of menus,but in SWT perhaps the changing is
hard to complete,so I want to embeded AWT MenuBar into SWT,after serveral
trys.I failed!!Other components such as Button etc can be embeded
successfully!!What is the reason?!
*****************************************
public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
shell.setText("am");
Composite composite = new Composite(shell, SWT.EMBEDDED);
Frame frame = SWT_AWT.new_Frame(composite);
frame.setLayout(new FlowLayout());
Button b=new Button("button");
b.setSize(50,50);
frame.add(b);
MenuBar menuBar;
// Menu file,edit;
//
//
//
menuBar=new MenuBar();
// file=new Menu();
//
// file.setLabel("file");
//
// menuBar.add(file);
// edit=new Menu();
// edit.setLabel("edit");
// menuBar.add(edit);
frame.setMenuBar(menuBar);
frame.setVisible(true);
shell.open();
while(!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
|
|
|
Re: Embeded AWT MenuBar Into SWT [message #444427 is a reply to message #444239] |
Tue, 12 October 2004 11:45  |
Eclipse User |
|
|
|
Nothing to do with SWT. This doesn't work for the same reason that you can't
embed an AWT menu bar in an applet.
"lianhw" <java_programmer@sohu.com> wrote in message
news:cka9po$4v5$1@eclipse.org...
> In order to change the style of menus,but in SWT perhaps the changing is
> hard to complete,so I want to embeded AWT MenuBar into SWT,after serveral
> trys.I failed!!Other components such as Button etc can be embeded
> successfully!!What is the reason?!
> *****************************************
>
> public static void main(String[] args) {
> final Display display = new Display();
> final Shell shell = new Shell(display);
> shell.setLayout(new FillLayout());
> shell.setText("am");
> Composite composite = new Composite(shell, SWT.EMBEDDED);
> Frame frame = SWT_AWT.new_Frame(composite);
> frame.setLayout(new FlowLayout());
> Button b=new Button("button");
> b.setSize(50,50);
> frame.add(b);
> MenuBar menuBar;
> // Menu file,edit;
> //
> //
> //
> menuBar=new MenuBar();
>
> // file=new Menu();
> //
> // file.setLabel("file");
> //
> // menuBar.add(file);
> // edit=new Menu();
> // edit.setLabel("edit");
> // menuBar.add(edit);
> frame.setMenuBar(menuBar);
>
> frame.setVisible(true);
>
> shell.open();
> while(!shell.isDisposed()) {
> if (!display.readAndDispatch()) display.sleep();
> }
> display.dispose();
> }
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.02559 seconds