Hi Ilya,
Welcome to Pivot! Thanks for bringing your questions to the list. Every question helps other people too!

So, to your question: it looks like the main .bxml you load is the modified "stock_tracker_window.bxml", and that you are trying to put a window into the middle of that TablePane. I'm not sure why you are doing that, but that is the main problem. I presume that your MenuBars class is derived from Window, which must be a top-level object (as the error message implies). A Window is not meant to be put inside other components, but to be the parent of other components. It looks to me like you could simply load your "menu2.bxml" as the main .bxml file of your application and everything would work fine.

HTH,
~Roger

On 3/23/14 3:42 PM, Ilya Zimnovich wrote:
Dear Apache Pivot experts,

I would like to add a top level menu bar to the application. I have
modified the StockTracker app's main window BXML file like this:

stock_tracker_window.bxml
....
     <TablePane styles="{padding:8, horizontalSpacing:6, verticalSpacing:6}">
         <columns>
             <TablePane.Column width="1*" />
         </columns>

         <TablePane.Row height="-1">
             <Border styles="{padding:6, color:10}">
                 <bxml:include src="menu_2.bxml"/>
             </Border>
         </TablePane.Row>

         <TablePane.Row height="-1">
             <Label text="%stockTracker"
                 styles="{font:{size:14, bold:true},
verticalAlignment:'center'}" />
         </TablePane.Row>
.....

After trying to run the application I always got:
Java.lang.RuntimeException
Error setting property "content" for type org.apache.pivot.wtk.Border to
value "com.expo.finance.MenuBars"
Caused by: java.lang.IllegalArgumentException: Window parent must be
null or display, cannot be org.apache.pivot.wtk.Border

Below is the source of "menu_2.bxml" file:
....
<menus:MenuBars title="Menu Bars" maximized="true"
     styles="{padding:{top:0, left:4, bottom:4, right:4},
showWindowControls:false}"
     xmlns:bxml="http://pivot.apache.org/bxml";
     xmlns:content="org.apache.pivot.wtk.content"
     xmlns:menus="com.expo.finance"
     xmlns="org.apache.pivot.wtk">
     <bxml:define>
         <FileBrowserSheet bxml:id="fileBrowserSheet"/>
     </bxml:define>

     <actionMappings>
         <Window.ActionMapping action="fileNew" keyStroke="CMD-N"/>
         <Window.ActionMapping action="fileOpen" keyStroke="CMD-O"/>
     </actionMappings>

     <menuBar>
         <MenuBar>
             <MenuBar.Item buttonData="File">
                 <Menu>
                     <Menu.Section>
                         <Menu.Item action="fileNew">
                             <buttonData>
                                 <content:MenuItemData text="New"
keyboardShortcut="CMD-N"/>
                             </buttonData>
                         </Menu.Item>

                         <Menu.Item action="fileOpen">
                             <buttonData>
                                 <content:MenuItemData text="Open"
keyboardShortcut="CMD-O"/>
                             </buttonData>
                         </Menu.Item>
                     </Menu.Section>
                 </Menu>
             </MenuBar.Item>

         </MenuBar>
     </menuBar>

</menus:MenuBars>
....

Best Regards,
Ilya A. Zimnovich




Reply via email to