01: package examples.swingdemos;
02:
03: import java.awt.event.*;
04:
05: import javax.swing.*;
06:
07: /**
08: * @author ges
09: * @author kwalrath
10: */
11:
12: public class MenuGlueDemo extends JFrame {
13: protected JMenuBar menuBar;
14:
15: public MenuGlueDemo() {
16: super ("MenuGlueDemo");
17: menuBar = new JMenuBar();
18: setJMenuBar(menuBar);
19: addNewMenu("Menu 1");
20: addNewMenu("Menu 2");
21: menuBar.add(Box.createHorizontalGlue());
22: addNewMenu("Menu 3");
23:
24: addWindowListener(new WindowAdapter() {
25: public void windowClosing(WindowEvent e) {
26: System.exit(0);
27: }
28: });
29: }
30:
31: public void addNewMenu(String title) {
32: JMenu m = menuBar.add(new JMenu(title));
33: m.add("Menu item");
34: m.add("Menu item");
35: m.add("Menu item");
36: }
37:
38: public static void main(String args[]) {
39: MenuGlueDemo f = new MenuGlueDemo();
40: f.setSize(300, 50);
41: f.setVisible(true);
42: }
43: }
|