# Popup Calendar size

**URL:** <https://forum.inductiveautomation.com/t/popup-calendar-size/67540>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [December 13, 2022, 5:20am UTC](https://forum.inductiveautomation.com/t/popup-calendar-size/67540 "2022-12-13T05:20:10Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dharani\_T](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dharani\_T](https://forum.inductiveautomation.com/u/Dharani_T)\
**Post date:** [December 13, 2022, 5:20am UTC](https://forum.inductiveautomation.com/t/popup-calendar-size/67540/1 "2022-12-13T05:20:10Z")

</div>

Hi,  
I have a vision window with popup calendar and it displays as below (font size-12),  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/4/4475a137baf7572fb66f6294c1ecee48e9d65865.png)  
I would like to reduce the size of the calendar (Day names). How to achieve this?

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [December 13, 2022, 6:37am UTC](https://forum.inductiveautomation.com/t/popup-calendar-size/67540/2 "2022-12-13T06:37:29Z")

</div>

Below is a script that changes the font size of the days only in a calendar component when fired from a button in the same container; it should be easily modifiable for your usage case. I would probably modify the jpanel's path and stick the script into the internalFrameOpened event handler of the parent window.

```auto
from java.awt import Font
fontSize = 8
font = Font('Dialog',0,fontSize)
jPanel = event.source.parent.getComponent('Calendar').getComponent(0).getComponent(1).getComponent(0).getComponent(1).getComponent(1)
sunLabel = jPanel.getComponent(0)
monLabel = jPanel.getComponent(1)
tueLabel = jPanel.getComponent(2)
wedLabel = jPanel.getComponent(3)
thuLabel = jPanel.getComponent(4)
friLabel = jPanel.getComponent(5)
satLabel = jPanel.getComponent(6)
weekLabels = [sunLabel, monLabel, tueLabel, wedLabel, thuLabel, friLabel, satLabel]
for label in weekLabels:
	label.setFont(font)

```

**The preceding script produces the following result:**  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/f/cfb615b7c0035d06f75d867ef2f6c009a4456b9f.png)

**Edit:** Here is a simpler refactored version of the script:

```auto
from java.awt import Font
fontSize = 8
font = Font('Dialog',0,fontSize)
jPanel = event.source.parent.getComponent('Calendar').getComponent(0).getComponent(1).getComponent(0).getComponent(1).getComponent(1)
for label in range(7):
	jPanel.getComponent(label).setFont(font)

```

---

<div class="post-metadata">

**Author:** ![Dharani\_T](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dharani\_T](https://forum.inductiveautomation.com/u/Dharani_T)\
**Post date:** [December 13, 2022, 6:58am UTC](https://forum.inductiveautomation.com/t/popup-calendar-size/67540/3 "2022-12-13T06:58:50Z")

</div>

Hey Justin,  
I am getting the below error,  
Traceback (most recent call last):  
File "event:internalFrameOpened", line 4, in   
TypeError: getComponent(): 1st arg can't be coerced to int  
Script I used:

```auto
from java.awt import Font
fontSize = 8
font = Font('Dialog',0,fontSize)
jPanel = event.source.parent.getComponent('EndDate_dropdown').getComponent(0).getComponent(1).getComponent(0).getComponent(1).getComponent(1)
for label in range(7):
	jPanel.getComponent(label).setFont(font)

```

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/a/cac3d1064fa18387a012ad25ace20dd0ae74792f.png)

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [December 13, 2022, 7:06am UTC](https://forum.inductiveautomation.com/t/popup-calendar-size/67540/4 "2022-12-13T07:06:31Z")

</div>

The path has to be changed to find the component from the parent window:

```auto
from java.awt import Font
fontSize = 8
font = Font('Dialog',0,fontSize)
calender = system.gui.getParentWindow(event).getComponentForPath('Root Container.Date_Group.EndDate_dropdown')
jPanel = calender.getComponent(0).getComponent(1).getComponent(0).getComponent(1).getComponent(1)
for label in range(7):
	jPanel.getComponent(label).setFont(font)

```

---

<div class="post-metadata">

**Author:** ![Dharani\_T](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dharani\_T](https://forum.inductiveautomation.com/u/Dharani_T)\
**Post date:** [December 13, 2022, 7:08am UTC](https://forum.inductiveautomation.com/t/popup-calendar-size/67540/5 "2022-12-13T07:08:49Z")

</div>

Now i am getting the below error,

```auto
Traceback (most recent call last):
  File "<event:internalFrameOpened>", line 5, in <module>
java.lang.ArrayIndexOutOfBoundsException: java.lang.ArrayIndexOutOfBoundsException: No such child: 1

	caused by ArrayIndexOutOfBoundsException: No such child: 1

Ignition v8.1.22 (b2022110109)
Java: Azul Systems, Inc. 11.0.16.1

```

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [December 13, 2022, 7:14am UTC](https://forum.inductiveautomation.com/t/popup-calendar-size/67540/6 "2022-12-13T07:14:47Z")

</div>

Interesting.  
What gets returned by this script?

```auto
calender = system.gui.getParentWindow(event).getComponentForPath('Root Container.Date_Group.EndDate_dropdown')
try:
	print type(calender)
	print type(calender.getComponent(0))
	print type(calender.getComponent(0).getComponent(1))
	print type(calender.getComponent(0).getComponent(1).getComponent(0))
	print type(calender.getComponent(0).getComponent(1).getComponent(0).getComponent(1))
	print type(calender.getComponent(0).getComponent(1).getComponent(0).getComponent(1).getComponent(1))
except:
	pass

```

Mine returns this:

```auto
<type 'com.inductiveautomation.factorypmi.application.components.PMIDateTimeSelector'>
<type 'com.inductiveautomation.ignition.client.util.gui.date_selector.Titled_date_selector'>
<type 'com.inductiveautomation.ignition.client.util.gui.date_selector.Navigable_date_selector'>
<type 'com.inductiveautomation.ignition.client.util.gui.date_selector.Time_date_selector'>
<type 'com.inductiveautomation.ignition.client.util.gui.date_selector.Date_selector_panel'>
<type 'javax.swing.JPanel'>

```

---

<div class="post-metadata">

**Author:** ![Dharani\_T](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dharani\_T](https://forum.inductiveautomation.com/u/Dharani_T)\
**Post date:** [December 13, 2022, 7:42am UTC](https://forum.inductiveautomation.com/t/popup-calendar-size/67540/7 "2022-12-13T07:42:36Z")

</div>

No. it is not returning.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/7/c7911b2708bf796f8dbd01cb5ce3334cb1fe7c7d.png)

```auto
from java.awt import Font
fontSize = 8
font = Font('Dialog',0,fontSize)
#calender = system.gui.getParentWindow(event).getComponentForPath('Root Container.Date_Group.EndDate_dropdown')
#jPanel = calender.getComponent(0).getComponent(1).getComponent(0).getComponent(1).getComponent(1)
#for label in range(7):
#	jPanel.getComponent(label).setFont(font)

print "Test"
calender = system.gui.getParentWindow(event).getComponentForPath('Root Container.Date_Group.EndDate_dropdown')
try:
	print type(calender)
	print type(calender.getComponent(0))
	print type(calender.getComponent(0).getComponent(1))
	print type(calender.getComponent(0).getComponent(1).getComponent(0))
	print type(calender.getComponent(0).getComponent(1).getComponent(0).getComponent(1))
	print type(calender.getComponent(0).getComponent(1).getComponent(0).getComponent(1).getComponent(1))
except:
	pass

```

For testing, I have added test print. It is working

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [December 13, 2022, 8:02am UTC](https://forum.inductiveautomation.com/t/popup-calendar-size/67540/8 "2022-12-13T08:02:52Z")

</div>

Oops. I see the problem. I wrote the script for a "_ **calendar** _" component, but you are using a "_ **popup calendar** _", so the calendar is not directly accessible through the getComponents() method. I'll take a look at the other component to see if I can do anything with it.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [December 13, 2022, 8:21am UTC](https://forum.inductiveautomation.com/t/popup-calendar-size/67540/9 "2022-12-13T08:21:53Z")

</div>

I found a way to do the same thing with the popup calendar. The following script was written for use on the popup calendar's mouseClicked event handler:

```auto
from java.awt import Font
fontSize = 8
font = Font('Dialog',0,fontSize)
popupCalender = event.source
calendar = popupCalender.getClass().getDeclaredField('popup')
calendar.setAccessible(True)
popup = calendar.get(popupCalender)
jPanel = popup.getComponent(0).getComponent(0).getComponent(1).getComponent(0).getComponent(1).getComponent(1)
for label in range(7):
	jPanel.getComponent(label).setFont(font)

```

Here is a version that will work from the internalFrameOpened event handler if that would be preferable:

```auto
from java.awt import Font
fontSize = 6
font = Font('Dialog',0,fontSize)
popupCalender = system.gui.getParentWindow(event).getComponentForPath('Root Container.Date_Group.EndDate_dropdown')
calendar = popupCalender.getClass().getDeclaredField('popup')
calendar.setAccessible(True)
popup = calendar.get(popupCalender)
jPanel = popup.getComponent(0).getComponent(0).getComponent(1).getComponent(0).getComponent(1).getComponent(1)
for label in range(7):
	jPanel.getComponent(label).setFont(font)

```

---

<div class="post-metadata">

**Author:** ![Dharani\_T](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dharani\_T](https://forum.inductiveautomation.com/u/Dharani_T)\
**Post date:** [December 13, 2022, 8:38am UTC](https://forum.inductiveautomation.com/t/popup-calendar-size/67540/10 "2022-12-13T08:38:39Z")

</div>

> [@justinedwards.jle](#):
>
> ```auto
> from java.awt import Font
> fontSize = 6
> font = Font('Dialog',0,fontSize)
> popupCalender = system.gui.getParentWindow(event).getComponentForPath('Root Container.Date_Group.EndDate_dropdown')
> calendar = popupCalender.getClass().getDeclaredField('popup')
> calendar.setAccessible(True)
> popup = calendar.get(popupCalender)
> jPanel = popup.getComponent(0).getComponent(0).getComponent(1).getComponent(0).getComponent(1).getComponent(1)
> for label in range(7):
> jPanel.getComponent(label).setFont(font)
> 
> ```

Again i am getting 'No such child' error

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [December 13, 2022, 8:46am UTC](https://forum.inductiveautomation.com/t/popup-calendar-size/67540/11 "2022-12-13T08:46:45Z")

</div>

hmmm...  
Try this script on the **popupCalendar's mouseEntered** _event handler_, and tell me if it has the desired effect:

```auto
from java.awt import Font
fontSize = 4
font = Font('Dialog',0,fontSize)
popupCalender = event.source
calendar = popupCalender.getClass().getDeclaredField('popup')
calendar.setAccessible(True)
popup = calendar.get(popupCalender)
jPanel = popup.getComponent(0).getComponent(0).getComponent(1).getComponent(0).getComponent(1).getComponent(1)
for label in range(7):
	jPanel.getComponent(label).setFont(font)

```

If that doesn't work, then I have exhausted my ideas.

---

<div class="post-metadata">

**Author:** ![Dharani\_T](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dharani\_T](https://forum.inductiveautomation.com/u/Dharani_T)\
**Post date:** [December 13, 2022, 8:50am UTC](https://forum.inductiveautomation.com/t/popup-calendar-size/67540/12 "2022-12-13T08:50:36Z")

</div>

> [@justinedwards.jle](#):
>
> ```auto
> from java.awt import Font
> fontSize = 4
> font = Font('Dialog',0,fontSize)
> popupCalender = event.source
> calendar = popupCalender.getClass().getDeclaredField('popup')
> calendar.setAccessible(True)
> popup = calendar.get(popupCalender)
> jPanel = popup.getComponent(0).getComponent(0).getComponent(1).getComponent(0).getComponent(1).getComponent(1)
> for label in range(7):
> jPanel.getComponent(label).setFont(font)
> 
> ```

```auto
Traceback (most recent call last):
  File "<event:mouseEntered>", line 8, in <module>
java.lang.ArrayIndexOutOfBoundsException: java.lang.ArrayIndexOutOfBoundsException: No such child: 1

	caused by ArrayIndexOutOfBoundsException: No such child: 1

Ignition v8.1.22 (b2022110109)
Java: Azul Systems, Inc. 11.0.16.1

```

Again !!?

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [December 13, 2022, 8:59am UTC](https://forum.inductiveautomation.com/t/popup-calendar-size/67540/13 "2022-12-13T08:59:58Z")

</div>

I'm just not sure. This is the result on my system:

[https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/8/080c53cf9847df2d0fb80fd6973d76a1837f494d.mp4](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/8/080c53cf9847df2d0fb80fd6973d76a1837f494d.mp4)

This approach must not be the correct way to go about isolating the day labels. All I've done is look through the sub components until I find the container that has the labels. Then I just loop through and apply the font change. Your component must be structured differently from mine.

---

<div class="post-metadata">

**Author:** ![Dharani\_T](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dharani\_T](https://forum.inductiveautomation.com/u/Dharani_T)\
**Post date:** [December 13, 2022, 9:21am UTC](https://forum.inductiveautomation.com/t/popup-calendar-size/67540/14 "2022-12-13T09:21:29Z")

</div>

Still, it did not worked. I endedup increasing the width of the component!! Will try to adapt this script to the component.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [December 13, 2022, 10:09am UTC](https://forum.inductiveautomation.com/t/popup-calendar-size/67540/15 "2022-12-13T10:09:52Z")

</div>

I had another idea on this. Here is an approach designed for the mouseEntered event handler that also works on my system except, instead of using specific subcomponents, it actually searches all of the subcomponents until it finds all of the labels:

```auto
from javax.swing import JLabel
from java.awt import Font
fontSize = 7
font = Font('Dialog',0,fontSize)
dayList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
dayListCount = 0
def dayLabelFinder(calendar):
	try:
		if calendar.componentCount > 0:
			for component in calendar.getComponents():
				try:
					if isinstance(component, JLabel) and component.getText() in dayList:
						component.setFont(font)
						dayListCount +=1
						if dayListCount == 7:
							return
					dayLabelFinder(component)
				except:
					pass
	except:
		pass
popupCalender = event.source
calendar = popupCalender.getClass().getDeclaredField('popup')
calendar.setAccessible(True)
popup = calendar.get(popupCalender)
dayLabelFinder(popup)

```

**Result:**  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/1/413054dd21f15369de84cefbd2d8a37264cf5830.png)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 13, 2022, 3:10pm UTC](https://forum.inductiveautomation.com/t/popup-calendar-size/67540/16 "2022-12-13T15:10:11Z")

</div>

Note that the variant of `getComponent()` that takes an integer will not deliver a component that is wrapped for full functionality in jython unless you have installed my Simulation Aids 3rd-party module. See this topic for the intricate details:

> [@Transaction groups triggered expression item updating when trigger is false](https://forum.inductiveautomation.com/t/transaction-groups-triggered-expression-item-updating-when-trigger-is-false/17196/14):
>
> Ok, so I’ve been down the rabbit hole and found Ignition’s (undocumented) PyComponentWrapper. I haven’t deciphered it enough to be sure, but it seems to be invoked only for particular situations, based on the string constants in the class file (like “getComponent” and “getComponents”). To play with this, I constructed a conversion adapter like so: public class PyComponentAdapter implements PyObjectAdapter { public PyComponentAdapter() {} @Override public boolean canAdapt(Object jObj) { …
