سؤال

I am writing a simple application using Apache Pivot. I have to write it in a code, not by using BXML.

I have the following code:

@Override
public void startup(Display display, Map<String, String> properties) {
    frame = new Frame();
    frame.setMinimumHeight(400);
    menuBar = new MenuBar();
    menuBar.setMinimumHeight(28);
    menuBar.setMinimumWidth(500);

    MenuBar.Item item = new MenuBar.Item("Menu1");
    Menu menu = new Menu();
    item.setMenu(menu);

    Menu.Section section = new Menu.Section();
    Menu.Item menuitem = new Menu.Item("Text");
    section.add(menuitem);
    menu.getSections().add(section);

    BoxPane boxPane = new BoxPane(Orientation.VERTICAL);
    TextArea area = new TextArea();
    area.setMinimumHeight(300);
    area.setMaximumHeight(300);
    area.setMinimumWidth(500);
    area.setMaximumWidth(500);
    boxPane.add(area);
    boxPane.getStyles().put("padding", "25");

    frame.setMenuBar(menuBar);

    frame.setContent(boxPane);
    frame.setTitle("Zkusebni Apache Pivot aplikace");
    frame.setMaximized(true);
    frame.open(display);
}

If i run this application, the result is following:

image link (sorry, I am not allowed to post images yet.)

Now when I for example change minimum height of menu bar like this:

//instead of
menuBar.setMinimumHeight(28);
//this
menuBar.setMinimumHeight(150);

Then the caret of text area moves down. So I think menu bar exist somewhere, but only isn't visible.

Could anybody help please?

Thanks

هل كانت مفيدة؟

المحلول

You need to add the Menu object to the MenuBar.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top