Prerequisites
Place the following code to User.js of your test.
var obj_type_filter = {
"java.awt.Label": true,
"java.awt.Button": true,
"java.awt.Checkbox": true,
"java.awt.TextField": true,
"java.awt.Choice": true,
"javax.swing.JButton": true
};
var saved_page_objects = {};
function RecordPageObjects( parent, fileName)
{
g_recording = true;
var obj = parent;
if (typeof(parent) == "string")
{
obj = SeS(parent);
}
RecordObject(obj);
File.Write(fileName, 'var saved_script_objects = ' + JSON.stringify(saved_page_objects, function(name,val) { if (name != "cached_instance") return val; }, "\t"));
}
function RecordObject(obj)
{
var cc = SeSGetJavaChildrenCount(obj.instance);
for(var i = 0; i < cc; i++)
{
var child = SeSGetJavaChildAt(obj.instance, i);
var cObj = null;
try
{
cObj = SeSTryMatch(child);
}
catch(e) {}
if (cObj)
{
var objClass = SeSGetJavaComponentType(child);
if (obj_type_filter[objClass])
{
var stringifiedObject = cObj.serializeSeSObject();
var objName = "";
var postfix = "";
var objInd = 1;
do
{
objName = cObj.getPreferredName() + postfix;
postfix = "" + objInd++;
} while(saved_page_objects[objName]);
saved_page_objects[objName] = JSON.parse(stringifiedObject);
}
RecordObject(cObj);
}
}
}
Adjust obj_type_filter to include classes of objects you want to automatically learn.
Usage
Capture all Child Objects in a Window
var pageObjectsFileName = "Page.Objects.js";
var wnd = g_util.FindWindow("AUTJAVA", "regex:.*");
if (wnd)
{
var cp = SeSGetJava(wnd);
if (cp)
{
var obj = SeSTryMatch(cp);
RecordPageObjects(obj, pageObjectsFileName);
}
}
This snippet finds the top Java object related to a window with given title (AUTJAVA in this example) and learns all the child objects. The result is saved to a file (Page.Objects.js). Put this snippet to the Main.js file of your test.
Capture All Child Objects of an Object
You may learn parent object with Java Spy. Start recording from the toolbar, launch Spy, track the object you need (climb parents if needed) and use Learn Object button in the Spy.

Now frame0 object is in the Object Tree. Put the following snippet to Main.js and run.
var pageObjectsFileName = "Page.Objects.js";
RecordPageObjects("frame0", pageObjectsFileName);
After execution all sub-objects (recursively) of frame0 will be stored to Page.Objects.js.
Loading Objects for Playback
Once you captured objects to Page.Objects.js or(if you have multi-screen application) to a set of files with objects you may load them with Global.DoLoadObjects.
var pageObjectsFileName = "Page.Objects.js";
Global.DoLoadObjects(pageObjectsFileName);
SeS("button1").DoClick();
Also when all objects are captured you may merge them into the Objects.js with Object Manager.