# Adding a listener for window size change

**URL:** <https://forum.inductiveautomation.com/t/adding-a-listener-for-window-size-change/16758>\
**Category:** Ignition\
**Tags:** ignition79, scripting\
**Created:** [January 26, 2018, 5:55pm UTC](https://forum.inductiveautomation.com/t/adding-a-listener-for-window-size-change/16758 "2018-01-26T17:55:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nimanamjouyan](https://avatars.discourse-cdn.com/v4/letter/n/f0a364/32.png) [@nimanamjouyan](https://forum.inductiveautomation.com/u/nimanamjouyan)\
**Post date:** [January 26, 2018, 5:55pm UTC](https://forum.inductiveautomation.com/t/adding-a-listener-for-window-size-change/16758/1 "2018-01-26T17:55:22Z")

</div>

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](http://forum.inductiveautomation.com/t/propertychange-event-when-window-change-it-size/11369/4)

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!!!

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [January 26, 2018, 8:59pm UTC](https://forum.inductiveautomation.com/t/adding-a-listener-for-window-size-change/16758/2 "2018-01-26T20:59:09Z")

</div>

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![nimanamjouyan](https://avatars.discourse-cdn.com/v4/letter/n/f0a364/32.png) [@nimanamjouyan](https://forum.inductiveautomation.com/u/nimanamjouyan)\
**Post date:** [January 29, 2018, 1:26am UTC](https://forum.inductiveautomation.com/t/adding-a-listener-for-window-size-change/16758/3 "2018-01-29T01:26:39Z")

</div>

Brilliant!! Just what I was after.
