Skip to content

Commit

Permalink
Improve sample app
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4a616e committed Dec 1, 2020
1 parent 071576c commit 441646c
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* "OS X Human Interface Guidelines"
*/
public class StandardMacApp extends Application {
static final String appName = "Standard";
static final String appName = "My macOS App";
static final String mainWindowTitle = "Main";
static final String childWindowTitle = "Child";

Expand Down Expand Up @@ -56,6 +56,7 @@ public void start(Stage primaryStage) throws Exception {
// Runtime
MenuItem aboutItem = tk.createAboutMenuItem(appName);
MenuItem prefsItem = new MenuItem("Preferences...");
prefsItem.setOnAction(this::handleEvent);
appMenu.getItems().addAll(aboutItem, new SeparatorMenuItem(), prefsItem, new SeparatorMenuItem(),
tk.createHideMenuItem(appName), tk.createHideOthersMenuItem(), tk.createUnhideAllMenuItem(),
new SeparatorMenuItem(), tk.createQuitMenuItem(appName));
Expand All @@ -68,7 +69,8 @@ public void start(Stage primaryStage) throws Exception {

// Edit
Menu editMenu = new Menu("Edit");
editMenu.getItems().addAll(new MenuItem("TBD"));
editMenu.getItems().addAll(createMenuItem("Undo"), createMenuItem("Redo"), new SeparatorMenuItem(),
createMenuItem("Cut"), createMenuItem("Copy"), createMenuItem("Paste"), createMenuItem("Select All"));

// Format
Menu formatMenu = new Menu("Format");
Expand All @@ -86,7 +88,7 @@ public void start(Stage primaryStage) throws Exception {

// Help Menu
Menu helpMenu = new Menu("Help");
helpMenu.getItems().addAll(new MenuItem("TBD"));
helpMenu.getItems().addAll(new MenuItem("Getting started"));

bar.getMenus().addAll(appMenu, fileMenu, editMenu, formatMenu, viewMenu, windowMenu, helpMenu);

Expand All @@ -95,8 +97,12 @@ public void start(Stage primaryStage) throws Exception {
tk.autoAddWindowMenuItems(windowMenu);
tk.setGlobalMenuBar(bar);
tk.setTrayMenu(createSampleMenu());
}

System.gc();
private MenuItem createMenuItem(String title) {
MenuItem menuItem = new MenuItem(title);
menuItem.setOnAction(this::handleEvent);
return menuItem;
}

private StackPane getRootPane() {
Expand Down

0 comments on commit 441646c

Please sign in to comment.