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 <[email protected]> > 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"> > <MenuBar.Item buttonData="Testmenu"> > <Menu.Section> > <Menu.Item> > <buttonData> > <content:MenuItemData text="New" keyboardShortcut="CMD-N"/> > </buttonData> > </Menu.Item> > </Menu.Section> > </MenuBar.Item> > </MenuBar> > > <Panel> > <bxml:include src="BookPanel.bxml" /> > </Panel> > </Window> > > What's wrong with that? > > >
