FileDocCategorySizeDatePackage
MenuExample.javaAPI DocExample2362Mon Nov 09 12:45:48 GMT 1998None

MenuExample

public class MenuExample extends JPanel

Fields Summary
public JTextPane
pane
public JMenuBar
menuBar
Constructors Summary
public MenuExample()

        super(true);

        menuBar = new JMenuBar();

        JMenu formatMenu = new JMenu("Justify");
        formatMenu.setMnemonic('J");

        MenuAction leftJustifyAction = new MenuAction("Left",
                                           new ImageIcon("left.gif"));
        MenuAction rightJustifyAction = new MenuAction("Right",
                                           new ImageIcon("right.gif"));
        MenuAction centerJustifyAction = new MenuAction("Center",
                                           new ImageIcon("center.gif"));
        MenuAction fullJustifyAction = new MenuAction("Full",
                                           new ImageIcon("full.gif"));

        JMenuItem item;
        item = formatMenu.add(leftJustifyAction);
        item.setMnemonic('L");
        item = formatMenu.add(rightJustifyAction);
        item.setMnemonic('R");
        item = formatMenu.add(centerJustifyAction);
        item.setMnemonic('C");
        item = formatMenu.add(fullJustifyAction);
        item.setMnemonic('F");

        menuBar.add(formatMenu);
        menuBar.setBorder(new BevelBorder(BevelBorder.RAISED));

    
Methods Summary
public static voidmain(java.lang.String[] s)


        MenuExample example = new MenuExample();
        example.pane = new JTextPane();
        example.pane.setPreferredSize(new Dimension(250, 250));
        example.pane.setBorder(new BevelBorder(BevelBorder.LOWERED));

        JFrame frame = new JFrame("Menu Example");
        frame.addWindowListener(new BasicWindowMonitor());
        frame.getContentPane().add(example.menuBar, BorderLayout.NORTH);
        frame.getContentPane().add(example.pane, BorderLayout.CENTER);
        frame.pack();
        frame.setVisible(true);