1 | void setEditAddEnabled(boolean enabled) {↵ | | 1 | void setEditAddEnabled(boolean enabled) {↵
|
2 | // There was a NPE being thrown without the null check here.. JKB↵ | | 2 | // There was a NPE being thrown without the null check here.. JKB↵
|
3 | if (edit_add != null) {↵ | | 3 | if (edit_add != null) {↵
|
4 | edit_add.setEnabled(enabled);↵ | | 4 | edit_add.setEnabled(enabled);↵
|
5 | }↵ | | 5 | }↵
|
6 | // If we are enabling the Edit-->Add menu item, then we also need to↵ | | 6 | // If we are enabling the Edit-->Add menu item, then we also need to↵
|
7 | // enable the Edit menu. The Edit menu may already be enabled, but↵ | | 7 | // enable the Edit menu. The Edit menu may already be enabled, but↵
|
8 | // there's no harm it trying to enable it again.↵ | | 8 | // there's no harm it trying to enable it again.↵
|
9 | if (enabled) {↵ | | 9 | if (enabled) {↵
|
10 | setEditEnabled(true);↵ | | 10 | setEditEnabled(true);↵
|
11 | } else {↵ | | 11 | } else {↵
|
12 | // If we are disabling the Edit-->Add menu item and the↵ | | 12 | // If we are disabling the Edit-->Add menu item and the↵
|
13 | // Edit-->Remove menu item is disabled, then we also need to↵ | | 13 | // Edit-->Remove menu item is disabled, then we also need to↵
|
14 | // disable the Edit menu.↵ | | 14 | // disable the Edit menu.↵
|
15 | // The Java Look and Feel Guidelines say to disable a menu if all↵ | | 15 | // The Java Look and Feel Guidelines say to disable a menu if all↵
|
16 | // menu items are disabled.↵ | | 16 | // menu items are disabled.↵
|
17 | if (!edit_remove.isEnabled()) {↵ | | 17 | if (!edit_remove.isEnabled()) {↵
|
18 | editMenu.setEnabled(false);↵ | | 18 | editMenu.setEnabled(false);↵
|
19 | }↵ | | 19 | }↵
|
20 | }↵ | | 20 | }↵
|
21 | }↵ | | 21 | }↵
|
|
22 | public void setEditRemoveEnabled(boolean enabled) {↵ | | 22 | public void setEditRemoveEnabled(boolean enabled) {↵
|
23 | edit_remove.setEnabled(enabled);↵ | | 23 | edit_remove.setEnabled(enabled);↵
|
24 | // If we are enabling the Edit-->Remove menu item, then we also need to↵ | | 24 | // If we are enabling the Edit-->Remove menu item, then we also need to↵
|
25 | // enable the Edit menu. The Edit menu may already be enabled, but↵ | | 25 | // enable the Edit menu. The Edit menu may already be enabled, but↵
|
26 | // there's no harm it trying to enable it again.↵ | | 26 | // there's no harm it trying to enable it again.↵
|
27 | if (enabled) {↵ | | 27 | if (enabled) {↵
|
28 | setEditEnabled(true);↵ | | 28 | setEditEnabled(true);↵
|
29 | } else {↵ | | 29 | } else {↵
|
30 | // If we are disabling the Edit-->Remove menu item and the↵ | | 30 | // If we are disabling the Edit-->Remove menu item and the↵
|
31 | // Edit-->Add menu item is disabled, then we also need to disable↵ | | 31 | // Edit-->Add menu item is disabled, then we also need to disable↵
|
32 | // the Edit menu.↵ | | 32 | // the Edit menu.↵
|
33 | // The Java Look and Feel Guidelines say to disable a menu if all↵ | | 33 | // The Java Look and Feel Guidelines say to disable a menu if all↵
|
34 | // menu items are disabled.↵ | | 34 | // menu items are disabled.↵
|
35 | if (!edit_add.isEnabled()) {↵ | | 35 | if (!edit_add.isEnabled()) {↵
|
36 | editMenu.setEnabled(false);↵ | | 36 | editMenu.setEnabled(false);↵
|
37 | }↵ | | 37 | }↵
|
38 | }↵ | | 38 | }↵
|
39 | }↵ | | 39 | }↵
|
|
40 | /**↵ | | 40 | /**↵
|
41 | * Creates the MenuBar for this application. I believe in my heart that this↵ | | 41 | * Creates the MenuBar for this application. I believe in my heart that this↵
|
42 | * should be defined in a file somewhere, but that is for later.↵ | | 42 | * should be defined in a file somewhere, but that is for later.↵
|
43 | */↵ | | 43 | */↵
|
44 | public void createMenuBar() {↵ | | 44 | public void createMenuBar() {↵
|
45 | makeFileMenu();↵ | | 45 | makeFileMenu();↵
|
46 | makeEditMenu();↵ | | 46 | makeEditMenu();↵
|
47 | makeRunMenu();↵ | | 47 | makeRunMenu();↵
|
48 | makeOptionsMenu();↵ | | 48 | makeOptionsMenu();↵
|
49 | makeHelpMenu();↵ | | 49 | makeHelpMenu();↵
|
50 | this.add(fileMenu);↵ | | 50 | this.add(fileMenu);↵
|
51 | this.add(editMenu);↵ | | 51 | this.add(editMenu);↵
|
52 | this.add(runMenu);↵ | | 52 | this.add(runMenu);↵
|
53 | this.add(optionsMenu);↵ | | 53 | this.add(optionsMenu);↵
|
54 | this.add(helpMenu);↵ | | 54 | this.add(helpMenu);↵
|
55 | } | | 55 | }
|