summaryrefslogtreecommitdiff
path: root/menus.java
blob: 25cc45cc62e7a0346e459dad35e0eeafde3a5ab6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;

/**
 * Test menus.
 *
 * @author Richard Evans
 */
public class menus {

  /**
   * Entry point.
   *
   * @param args None
   */

  public static void main(String[] args) {
    JFrame jframe = new JFrame("frame");
    JMenuBar mb = new JMenuBar();

    for (int i = 1; i <= 5; i++) {
      JMenu m = new JMenu("Menu " + i);

      for (int j = 1; j <= 5; j++) {
        JMenuItem mi = new JMenuItem("Item " + i + j);
        m.add(mi);
      }

      mb.add(m);
    }

    jframe.setJMenuBar(mb);

    JPanel jp = new JPanel();
    jp.setPreferredSize(new Dimension(500, 500));

    jframe.getContentPane().add(jp);
    jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    jframe.pack();
    jframe.setVisible(true);
  }

}