These properties are generated automatically using the JavaBean Introspector which identifies properties either from common design patterns, or from explicitly specified BeanInfo.
As a first example, consider the case where you wish to create a button that is disabled.
The first example shows how you would do this in the typical Java fashion:
The second example shows how enabled can be set as a property:b = awt.Button() b.setEnabled(0)
The final example sets this property at instantiation time using a keyword argument:b = awt.Button() b.enabled = 0
b = awt.Button(enabled=0)
It can also be handy for specifying color as an RGB triple:frame = awt.Frame(size=(500,100))
will set the background color of the frame to yellow.frame.background = 255,255,0
The standard Java style for setting an event listener is shown below:
class action(awt.event.ActionListener):
def actionPerformed(self,event):
java.lang.System.exit(0)
button = awt.Button("Close Me!")
button.addActionListener(action())
This can be written in a more Pythonesque (and compact) style by using
event properties as follows:
def exit(event):
java.lang.System.exit(0)
button = awt.Button("Close Me!", actionPerformed=exit)
properties < event-properties < fields < methodsThis means that a method will override a field with the same name. Some carefull handling of properties and static fields allow for the existence of, and access to, both an instance property and a static field with the same name.