Try this, Jython is a structured language so white space matters. Where many languages have brackets to determine scope, Python/Jython uses white space for this. Use two spaces for indention or a tab
if event.propertyName == 'text':
button = event.source.parent.getComponent('button 2')
button.doClick()