Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Embeded AWT MenuBar Into SWT
Embeded AWT MenuBar Into SWT [message #444239] Sun, 10 October 2004 03:26 Go to next message
lianhongwu is currently offline lianhongwuFriend
Messages: 17
Registered: July 2009
Junior Member
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 15:45 Go to previous message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
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();
> }
>
>
Previous Topic:example plug-ins
Next Topic:make the "Help" MenuItem in the right of the menuBar
Goto Forum:
  


Current Time: Fri Apr 19 22:13:47 GMT 2024

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

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

Back to the top