FileDocCategorySizeDatePackage
Menus.javaAPI DocExample7220Mon Apr 06 18:10:26 BST 1998c13.swing

Menus

public class Menus extends JPanel

Fields Summary
static final Boolean
bT
static final Boolean
bF
static final MType
mi
static final MType
cb
static final MType
rb
JTextField
t
JLabel
l
ActionListener
a1
ActionListener
a2
public Object[]
fileMenu
public Object[]
editMenu
public Object[]
helpMenu
public Object[]
optionMenu
public Object[]
faceMenu
public Object[]
menuBar
static ButtonGroup
bgroup
Constructors Summary
Menus()

    setLayout(new BorderLayout());
    add(createMenuBar(menuBar), 
      BorderLayout.NORTH);
    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());
    p.add(t, BorderLayout.NORTH);
    p.add(l, BorderLayout.CENTER);
    add(p, BorderLayout.CENTER);
  
Methods Summary
public static JMenucreateMenu(java.lang.Object[][] menuData)

    JMenu menu = new JMenu();
    menu.setText((String)menuData[0][0]);
    menu.setMnemonic(
      ((Character)menuData[0][1]).charValue());
    // Create redundantly, in case there are
    // any radio buttons:
    bgroup = new ButtonGroup();
    for(int i = 1; i < menuData.length; i++) {
      if(menuData[i][0] == null)
        menu.add(new JSeparator());
      else
        menu.add(createMenuItem(menuData[i]));
    }
    return menu;
  
public static JMenuBarcreateMenuBar(java.lang.Object[] menuBarData)

    
    
    JMenuBar menuBar = new JMenuBar();
    for(int i = 0; i < menuBarData.length; i++)
      menuBar.add(
        createMenu((Object[][])menuBarData[i]));
    return menuBar;
  
public static JMenuItemcreateMenuItem(java.lang.Object[] data)

    JMenuItem m = null;
    MType type = (MType)data[1];
    if(type == mi)
      m = new JMenuItem();
    else if(type == cb)
      m = new JCheckBoxMenuItem();
    else if(type == rb) {
      m = new JRadioButtonMenuItem();
      bgroup.add(m);
    }
    m.setText((String)data[0]);
    m.setMnemonic(
      ((Character)data[2]).charValue());
    m.addActionListener(
      (ActionListener)data[3]);
    m.setEnabled(
      ((Boolean)data[4]).booleanValue());
    if(data.length == 6)
      m.setIcon((Icon)data[5]);
    return m;
  
public static voidmain(java.lang.String[] args)

    Show.inFrame(new Menus(), 300, 200);