At the beginning, the program event was triggered by firepropertychanged. Later, I wanted to change it to a script to dynamically configure the game framework. Obviously, I cannot specify which key/button corresponds to any event in the code. I have only been familiar with Eclipse plug-ins and some knowledge about Java keyboard binding, so I followed the feeling and made a dynamic loading framework based on my own ideas.
Buttons -- trigger --> action:The Java buttons are used to bind inputmap & actionmap.
Button -- trigger --> action:This association is done manually. Using actionid to associate a specific action is jbutton. setaction (). Of course, the component is created in the interpreter scriptloader.
Share actions:Create a Global static actionmap. All events are added to the actionmap when they are loaded. put (ID, action), the following control can obtain the corresponding action according to the ID, this must be in the order of loading, otherwise the processing Code cannot be shared.
Describes the XML format of hotkey:
<Hotkey keycode = "W" Mask = "Alt"Actionid = "com. jmhxy. dialogs. Character status"/>
Describe the XML format of the button:
<ButtonActionid = "com. jmhxy. dialogs. Character status"X = "106" Y = "3" was = "/resources/character welement/profile picture/feiyan female. Was"/>
XML format of the description action:
<ActionId = "com. jmhxy. dialogs. Character status"Class = "com. jmhxy. Actions. hotkeyactions"/>
In this way, events and targets are associated by ID. The Interpreter analyzes XML elements and attributes, loads processing classes through class reflection, and obtains instances.