Try changing it to something like this:<bar:MainWindow title="SemanticNotes" maximized="true" xmlns:bxml="http://pivot.apache.org/bxml"xmlns:foo="com.foo.bar" xmlns="org.apache.pivot.wtk">replacing "foo" and "com.foo.bar" with your preferred namespace prefix and the name of the package containing MainWindow. As written, you are simply creating an instance of org.apache.pivot.wtk.Window, which is probably not what you want.Also, if you don't want to set the menu bar using a <menuBar> element, you should probably wrap the <MenuBar> in a <bxml:define> block. Otherwise, it will be set as the Window's content, then replaced by the Panel when that element is processed.GOn Mar 3, 2011, at 10:34 AM, Daniel Ziltener wrote:No, it isn't a typo. But I changed it to MainWindow, now. But it doesn't change anything.
I did assign an id to the menuBar: "<MenuBar xmlns:content="org.apache.pivot.wtk.content" bxml:id="menuBar">".As I now found out, "initialize" never gets called. So I moved the code "setMenu" into the startup method. That doesn't work, too. And I know why: The menuBar instance doesn't get assigned to my menuBar variable.2011/3/3 Greg Brown <firstname.lastname@example.org>The root element in your example is Window, not MainWindow - is that a typo?Couple other questions:1) Why call setMenu() manually? Why not just declare the menu in BXML?2) Is it possible that you did not assign an ID to your menu bar so that your menuBar member variable is null when initialize() is called?On Mar 3, 2011, at 10:19 AM, Daniel Ziltener wrote:Hi all,It's me again... I'm trying to add a MenuBar to a window I created. So I have a class MainWindow and a corresponding MainWindow.bxml.The MainWindow extends Frame and implements Application and Bindable and is essentially built like the "Menu Bars" sample on the pivot page, except that I manually add the MenuBar:I have a "@BXML MenuBar menuBar = null" which gets injected and then I use "this.setMenuBar(menuBar)" in the initialize-Method to add the MenuBar to the window. The problem is: There is no menubar displayed. I just keep getting a window without a menubar.My BXML-File is quite short, so I include it:<?xml version="1.0" encoding="UTF-8"?>
<Window title="SemanticNotes" maximized="true" xmlns:bxml="http://pivot.apache.org/bxml" xmlns="org.apache.pivot.wtk">
<MenuBar xmlns:content="org.apache.pivot.wtk.content" bxml:id="menuBar">
<content:MenuItemData text="New" keyboardShortcut="CMD-N"/>
<bxml:include src="BookPanel.bxml" />
</Window>What's wrong with that?