There is a property name that you can use:
newButton.setName(String.valueOf(objectCounter))
you can also use clientProperties, which allows you to store arbitrary values:
newButton.putClientProperty("id", Integer.valueOf(objectCounter))
To get the value from the client property map, you need something like this.
Object property = newButton.getClientProperty("id");
if (property instanceof Integer) {
int objectCounter = ((Integer)property);
}
source
share