Reputation: 57
I have customized my form titlebar and added buttons to it. Is it possible to add a listener to one of the buttons to add command(s) an overflow menu and show it.
Upvotes: 1
Views: 330
Reputation: 1907
Please try this it displays overflow menu when you click on button.
void showOverFlow(final Form f) {
Toolbar toolbar = new Toolbar();
f.setToolBar(toolbar);
toolbar.addCommandToOverflowMenu(new Command("overflow"));
Button button = new Button("show menu");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (f.getToolbar() != null) {
MenuBar mb = f.getToolbar().getMenuBar();
if (mb != null) {
mb.showMenu();
}
}
}
});
toolbar.addComponent(BorderLayout.WEST,button);
}
Upvotes: 0
Reputation: 1907
Yes, command/s can be added to overflow menu by using the following codes and actionPerformed is called when click on the command
Toolbar toolbar = new Toolbar();
f.setToolbar(toolbar);
toolbar.addCommandToOverflowMenu(new Command("Test") {
@Override
public void actionPerformed(ActionEvent evt) {
showForm("NewForm",null);
}
});
Upvotes: 2