Adding a listener for window size change

Since the size of a window is not a bindable property, I can not use it as a property change event for when the size of my window changes. I came across a post which suggested adding a listener would do the job:

The aforementioned useful post

Although the links to explain the java listener were very good and comprehensive, I could not work out how to add it to my window. I believe it needs to be added in the custom method section. But could you please show me a basic example of how one would add a listener in there?

Many thanks!!!

Add the following to your visionWindowOpened event. Change the methods are required, and remove ones that are not needed.

from java.awt.event import ComponentAdapter
class MyListener(ComponentAdapter):
	def componentResized(self,e):
		print e
	def componentShown(self,e):
		print e
	def componentHidden(self,e):
		print e
	def componentMoved(self,e):
		print e
event.source.addComponentListener(MyListener())

If you have any questions, please do not hesitate to ask.

4 Likes

Brilliant!! Just what I was after.