This is an implementation of a menu bar similar to other gui frameworks. To construct a menu control add
Menu objects into the MenuBar object. Each menu object itself contains MenuItem objects.

In the MenuBar the Menu is represented as a hover button (hover effect is not supported by all browsers),
which can be selected via mouse click. If so, the selected menu pops up and the menus items are displayed.

ln the Example Section you will find an introduction into configuring a MenuBar with the graphical designer as well as a brief code example.


Properties of the MenuBar can be easily set in the Property-Editor of the W4T Eclipse Perspective. Here is a description how to create a MenuBar manually for an application:

Just add the MenuBar Component to an arbitraty WebForm / WebPanel and select the item property (the three dots ...) from the property view. A window will appear where you can enter, delete and change the order of elements. If you create a Menu named File this Menu will appear in the outline view on the left side.

Selecting this Menu an item property will be available again, so you can now add MenuItems with the item editor. The MenuItems will remain inactiv, as long as there is no Event associated with the MenuItem. To add an Event select the desired MenuItem in the Outline View and go to the Events View (which is probably hidden below the Property View). Just enable the WebActionPerformed Propery of the New MenuItem by clicking the plus sign.

As soon as you save the file and thus it is getting compiled the New MenuItem will become activ. To add some code to be executed when the MenuItem is selected go to the Java Editor and select the doNewWebActionPerformed method from the Outline View. Just add your code here, the example below will open a window with a message

Important Notice

Actions are not executed in the Designer Editor, so if you want to test an action you should select the "Run as" -> "W4 Toolkit Application" from the "Run" Menu of Eclipse. This will open any WebForm in a browser window. More information is available here.

  private void doNewWebActionPerformed( WebActionEvent e ) throws Exception {
    W4TContext.addMessage( new Message("Hello World"));

Tip: After adding code to the class it may become nessecary to add additional import statements, the easiest way to do this is to press Strg-Shift-o for "Organize Imports" and Eclipse will take care of that.

API documentation

The API documentation for MenuBar can be found here.