Example usage for javax.swing JMenu getActionCommand

List of usage examples for javax.swing JMenu getActionCommand

Introduction

In this page you can find the example usage for javax.swing JMenu getActionCommand.

Prototype

public String getActionCommand() 

Source Link

Document

Returns the action command for this button.

Usage

From source file:TreeUtil.java

/** Creates the menus by using recursion */
public JMenuItem getMenus(DefaultMutableTreeNode node, JMenu parentMenu) {
    String name = node.getUserObject().toString();
    int numChild = node.getChildCount();
    if (numChild < 1) {
        JMenuItem tempMenu = new JMenuItem(name);
        tempMenu.setActionCommand(parentMenu.getActionCommand() + "." + name);
        tempMenu.addActionListener(this);
        return tempMenu;
    }//from  www.  j  a  va2s.com
    JMenu tempMenu = new JMenu(name);
    tempMenu.setActionCommand(parentMenu.getActionCommand() + "." + name);
    tempMenu.addActionListener(this);
    for (int i = 0; i < numChild; i++) {
        tempMenu.add(getMenus((DefaultMutableTreeNode) node.getChildAt(i), tempMenu));
    }
    return tempMenu;
}