NX Open Programmer's Guide > Execution Methods > Programs, Journals, or Callbacks from New Menu Items > Callback Registration for NX Open for Java
Callback Registration for NX Open for Java
The addMenuAction method (on menuBarManager) registers a callback with NX. The name passed must match the string used as the ACTIONS value in the menu file (e.g. "my_app_hello", "my_app_goodbye"). The example (HelloGoodbye.java) registers the entire HelloGoodbye class for both actions in an initializeCallbacks method; since one class handles two behaviors, its actionCallback method determines which button invoked the callback before dispatching to helloCB or goodbyeCB. After compiling, HelloGoodbye.class goes in the startup folder alongside a matching example menu file.
Compilation (Windows)
- Copy
HelloGoodbye.javaandHelloGoodbye_Makefile_winto your machine. - Start the NX command prompt (Start → Programs, same cluster as the NX shortcut).
cdto the folder containing the files.- Run:
nmake -f Makefile_win
Compilation (non-Windows)
- Copy
HelloGoodbye.javaandHelloGoodbye_Makefileto your machine. - Run
ugmenu, select "UGOPEN-API" → "Non-menu activities" → the shell type. cdto the folder containing the files.- Run:
make
Source structure (HelloGoodbye.java)
import nxopen.*;
import nxopen.menubar.*;
// HelloGoodbye class demos a custom application with two menu callbacks,
// registering itself as the handler and dispatching in actionCallback()
// to helloCB() or goodbyeCB() based on which button fired the event.
Related Topics
- Programs, Journals, or Callbacks from New Menu Items — Overview
- Introduction to Menu Files
- Executing Programs
- Executing Journals
- Executing Callbacks (Menu Event Handlers)
- Callback Registration for NX Open for C++
- Callback Registration for NX Open for .NET
Source: https://docs.sw.siemens.com/en-US/doc/209349590/PL20220512394070742.nxopen_prog_guide/new_menu_Java · retrieved Tue Jul 07 2026 00:00:00 GMT+0000 (Coordinated Universal Time)