# \[IGN-5677\]Size of PopupMenu

**URL:** <https://forum.inductiveautomation.com/t/ign-5677-size-of-popupmenu/42068>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [January 8, 2021, 5:27pm UTC](https://forum.inductiveautomation.com/t/ign-5677-size-of-popupmenu/42068 "2021-01-08T17:27:54Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Icom](https://avatars.discourse-cdn.com/v4/letter/i/e68b1a/32.png) [@Icom](https://forum.inductiveautomation.com/u/Icom)\
**Post date:** [January 8, 2021, 5:27pm UTC](https://forum.inductiveautomation.com/t/ign-5677-size-of-popupmenu/42068/1 "2021-01-08T17:27:55Z")

</div>

Hi,  
There is any way to change the size of a PopupMenu. Actually i’m using menu = system.gui.createPopupMenu to generate a Popup, the problem is that the Popup is to small (it doesn’t have à scrollbar). I need to show more the 50 items.  
Have you any idea how put un scrollbar or change the size of a popup?

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

I’m using Vision 8.1.

Thanks

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 8, 2021, 6:26pm UTC](https://forum.inductiveautomation.com/t/ign-5677-size-of-popupmenu/42068/2 "2021-01-08T18:26:13Z")

</div>

You can reach into advanced Swing coding and create your own popup menu - I’d suggest using [`JidePopupMenu`](http://www.jidesoft.com/javadoc/com/jidesoft/swing/JidePopupMenu.html) as your base class, because it has some builtin niceties, such as scrolling if your menu items won’t fit on the screen. There’s probably some examples floating around this forum to get you started on the custom menu aspect.

---

<div class="post-metadata">

**Author:** ![Icom](https://avatars.discourse-cdn.com/v4/letter/i/e68b1a/32.png) [@Icom](https://forum.inductiveautomation.com/u/Icom)\
**Post date:** [January 12, 2021, 10:16am UTC](https://forum.inductiveautomation.com/t/ign-5677-size-of-popupmenu/42068/3 "2021-01-12T10:16:24Z")

</div>

Hi PGriffith,  
I have tried to use the object but I do not have the necessary Java skills to do it. Can you guide me to some website or give me an idea to get started? How can I implement your suggestion in Ignition. I would really appreciate your help.  
Thanks a lot

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 12, 2021, 4:22pm UTC](https://forum.inductiveautomation.com/t/ign-5677-size-of-popupmenu/42068/4 "2021-01-12T16:22:29Z")

</div>

Low level Jython tutorials are few and far between. This is one resource that, on skimming, is at least accurate, although it looks like the formatting's been destroyed from whatever the original source was:

> **[Menus Event Handling - Jython - Python Studio](https://www.pythonstudio.us/jython/menus-event-handling.html)**
>
> The menu just created should look like the one in Figure 14-5 (if not, try manually resizing the frame). It's pretty, but it doesn't do anything. We need to

Honestly, lots of google results end up on this forum. Like I mentioned, there's some resources to be had:

> [@Icon beside each item in popup menu](http://forum.inductiveautomation.com/t/icon-beside-each-item-in-popup-menu/11663):
>
> Hi! I was wondering if it is possible to add icons on the left side of each item in the popup menu. And how am I going to do this. Thank you very much! slight_smile

---

<div class="post-metadata">

**Author:** ![Icom](https://avatars.discourse-cdn.com/v4/letter/i/e68b1a/32.png) [@Icom](https://forum.inductiveautomation.com/u/Icom)\
**Post date:** [January 13, 2021, 6:35am UTC](https://forum.inductiveautomation.com/t/ign-5677-size-of-popupmenu/42068/5 "2021-01-13T06:35:46Z")

</div>

Hi,  
Thanks for your answer. I’ll take a look.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 21, 2021, 9:30pm UTC](https://forum.inductiveautomation.com/t/ign-5677-size-of-popupmenu/42068/7 "2021-01-21T21:30:00Z")

</div>

What’s the full stack trace (click ‘full’) on that NullPointerException?

---

<div class="post-metadata">

**Author:** ![Icom](https://avatars.discourse-cdn.com/v4/letter/i/e68b1a/32.png) [@Icom](https://forum.inductiveautomation.com/u/Icom)\
**Post date:** [January 21, 2021, 9:36pm UTC](https://forum.inductiveautomation.com/t/ign-5677-size-of-popupmenu/42068/8 "2021-01-21T21:36:30Z")

</div>

Hi PGriffith,  
Here is the full stack:

```auto
Traceback (most recent call last):
  File "<event:mousePressed>", line 117, in <module>
	at com.inductiveautomation.factorypmi.application.script.builtin.WindowUtilities.createPopupMenu(WindowUtilities.java:728)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
java.lang.NullPointerException: java.lang.NullPointerException

	at org.python.core.Py.JavaError(Py.java:552)
	at org.python.core.Py.JavaError(Py.java:543)
	at org.python.core.PyReflectedFunction. __call__ (PyReflectedFunction.java:190)
	at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction. __call__ (ScriptManager.java:523)
	at org.python.core.PyObject. __call__ (PyObject.java:497)
	at org.python.core.PyObject. __call__ (PyObject.java:501)
	at org.python.pycode._pyx24.f$0(<event:mousePressed>:118)
	at org.python.pycode._pyx24.call_function(<event:mousePressed>)
	at org.python.core.PyTableCode.call(PyTableCode.java:171)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1614)
	at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:781)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:206)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:297)
	at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:57)
	at com.sun.proxy.$Proxy59.mousePressed(Unknown Source)
	at java.desktop/java.awt.AWTEventMulticaster.mousePressed(Unknown Source)
	at java.desktop/java.awt.Component.processMouseEvent(Unknown Source)
	at java.desktop/javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.Component.processEvent(Unknown Source)
	at java.desktop/java.awt.Container.processEvent(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.NullPointerException
	at com.inductiveautomation.factorypmi.application.script.builtin.WindowUtilities.createPopupMenu(WindowUtilities.java:728)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.python.core.PyReflectedFunction. __call__ (PyReflectedFunction.java:188)
	... 44 more

Ignition v8.1.0 (b2020110211)
Java: Azul Systems, Inc. 11.0.7

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 21, 2021, 10:29pm UTC](https://forum.inductiveautomation.com/t/ign-5677-size-of-popupmenu/42068/9 "2021-01-21T22:29:50Z")

</div>

You didn’t post the full code, but some item in your `funcs` list is null/nonexistent.

---

<div class="post-metadata">

**Author:** ![Icom](https://avatars.discourse-cdn.com/v4/letter/i/e68b1a/32.png) [@Icom](https://forum.inductiveautomation.com/u/Icom)\
**Post date:** [April 14, 2021, 9:29pm UTC](https://forum.inductiveautomation.com/t/ign-5677-size-of-popupmenu/42068/11 "2021-04-14T21:29:28Z")

</div>

Hi PGriffith:  
It has been some time since the last time. In fact, I have had to attack other points of the application in which I am working. Now I have a little more time and I have taken up the problem of this topic. However, I am still stuck, here is what I have done:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/1/a1b2442c749b1acd44279e6607bad78fec857d17.png)  
Here is the result:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/3/839cb6f876e4c1a40fab0c64669e2f3231c53e39.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/3/6305024e101febfda1c0ec9e6ddd6e166e449887.png)

The scrollbar still does not appear. If I not wrong, the JpopupMenu have acces of all attributs of Jcomponent, so the scrollable attribute. So, I don’t understand why it doesn’t appear.

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

Could you tell me where is the problem?

Thanks

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 14, 2021, 10:02pm UTC](https://forum.inductiveautomation.com/t/ign-5677-size-of-popupmenu/42068/12 "2021-04-14T22:02:10Z")

</div>

JPopupMenus don’t automatically scroll, and you’re making a `JyPopupMenu` anyways. You _must_ use `JidePopupMenu` as your base class if you want the automatic scrolling behavior. The code to add new items should be basically the same.

---

<div class="post-metadata">

**Author:** ![Icom](https://avatars.discourse-cdn.com/v4/letter/i/e68b1a/32.png) [@Icom](https://forum.inductiveautomation.com/u/Icom)\
**Post date:** [April 14, 2021, 10:06pm UTC](https://forum.inductiveautomation.com/t/ign-5677-size-of-popupmenu/42068/13 "2021-04-14T22:06:50Z")

</div>

> [@paul-griffith](#):
>
> JidePopupMenu

Thanks for you help,  
I've made your suggested but the problem is still there:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/0/20345c44868e6e3d9e2644074a442dcfd238b5bf.png)  
Here is the code:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/c/6c48c5d2facdbbb7a4314c7d2da2368d9e8b1160.png)  
No automatic scrolling appears.

Thanks again

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 14, 2021, 10:12pm UTC](https://forum.inductiveautomation.com/t/ign-5677-size-of-popupmenu/42068/14 "2021-04-14T22:12:15Z")

</div>

What if you manually give it a maximum number of items to display?  
[http://www.jidesoft.com/javadoc/com/jidesoft/swing/JidePopupMenu.html#setVisibleMenuItemCount(int)](http://www.jidesoft.com/javadoc/com/jidesoft/swing/JidePopupMenu.html#setVisibleMenuItemCount(int))

---

<div class="post-metadata">

**Author:** ![Icom](https://avatars.discourse-cdn.com/v4/letter/i/e68b1a/32.png) [@Icom](https://forum.inductiveautomation.com/u/Icom)\
**Post date:** [April 14, 2021, 10:24pm UTC](https://forum.inductiveautomation.com/t/ign-5677-size-of-popupmenu/42068/15 "2021-04-14T22:24:52Z")

</div>

> [@paul-griffith](#):
>
> of items to disp

The same result:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/5/9524a868fbea61567adb8a04084f6494b800953b.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/9/291d6ae6868af5e4ac933a4a30a00b86b1c9ea8e.png)

If a write:  
menu.visibleMenuItemCount(-1)  
I get an error:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/0/f052ddced1aa434ab8735b86730379fd9c9b44a4.png)  
Are you agre with me, that the scrolling is a native "fonction" of JidePopup.?

Thanks

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 14, 2021, 10:32pm UTC](https://forum.inductiveautomation.com/t/ign-5677-size-of-popupmenu/42068/16 "2021-04-14T22:32:53Z")

</div>

It’s not my component, but yes, it’s supposed to do what you want:

```auto
public class JidePopupMenu
extends JPopupMenu
implements Scrollable

This component extends JPopupMenu and adds a method to display the menu inside the screen even if the mouse pointer is near the edge of the screen.

It also puts the menu items into a scroll pane. When there are too many menu items that can't fit into one screen, the scroll pane will scroll up and down so that you can still get to all menu items.

```

I don’t know why it’s not doing what it’s supposed to.

---

<div class="post-metadata">

**Author:** ![Icom](https://avatars.discourse-cdn.com/v4/letter/i/e68b1a/32.png) [@Icom](https://forum.inductiveautomation.com/u/Icom)\
**Post date:** [April 14, 2021, 10:39pm UTC](https://forum.inductiveautomation.com/t/ign-5677-size-of-popupmenu/42068/17 "2021-04-14T22:39:53Z")

</div>

Thanks for your help. If you have any idea about how figure out the problem. I appreciate. Thanks again.

---

<div class="post-metadata">

**Author:** ![ray.crowder](https://avatars.discourse-cdn.com/v4/letter/r/e480ec/32.png) [@ray.crowder](https://forum.inductiveautomation.com/u/ray.crowder)\
**Post date:** [March 7, 2022, 4:13pm UTC](https://forum.inductiveautomation.com/t/ign-5677-size-of-popupmenu/42068/18 "2022-03-07T16:13:45Z")

</div>

Any update on this? Would love to have a solid way to implement a scroll bar on the popup menu.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 7, 2022, 4:28pm UTC](https://forum.inductiveautomation.com/t/ign-5677-size-of-popupmenu/42068/19 "2022-03-07T16:28:25Z")

</div>

JYPopupMenu as the base class shows a scroll bar. I wouldn’t recommend running this out of the script console, though that’s where I wrote it:

```auto
from javax.swing import JMenuItem
from de.javasoft.widgets import JYPopupMenu
from functools import partial

menu = JYPopupMenu()

def saySomething(event, message):
	system.gui.messageBox(message, "Event")
	
messages = [str(i) for i in range(1, 100)]

for message in messages:
	handler = partial(saySomething, message=message)
	item = JMenuItem("Say %s" % message, actionPerformed=handler)
	menu.add(item)
	
menu.show(None, 1280, 800)

```

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

---

<div class="post-metadata">

**Author:** ![ray.crowder](https://avatars.discourse-cdn.com/v4/letter/r/e480ec/32.png) [@ray.crowder](https://forum.inductiveautomation.com/u/ray.crowder)\
**Post date:** [March 7, 2022, 6:13pm UTC](https://forum.inductiveautomation.com/t/ign-5677-size-of-popupmenu/42068/20 "2022-03-07T18:13:14Z")

</div>

This is great and works as expected, thanks!

Can this script be adapted to maintain the nested list functionality of system.gui.createPopupMenu? It gets hung up when passing the submenu names and functions.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 7, 2022, 6:27pm UTC](https://forum.inductiveautomation.com/t/ign-5677-size-of-popupmenu/42068/21 "2022-03-07T18:27:15Z")

</div>

Instead of creating `JMenuItems`, create your own `JMenu`s (sibling import to `JMenuItem`) and add your nested menus to them.  
Constructing that automatically I’ll leave as an exercise for the reader. We could probably change `system.gui.createPopupMenu` to use this different base class automatically, but it won’t happen anytime soon, so you’re probably still better off using a workaround.

---

<div class="post-metadata">

**Author:** ![ray.crowder](https://avatars.discourse-cdn.com/v4/letter/r/e480ec/32.png) [@ray.crowder](https://forum.inductiveautomation.com/u/ray.crowder)\
**Post date:** [March 7, 2022, 6:38pm UTC](https://forum.inductiveautomation.com/t/ign-5677-size-of-popupmenu/42068/22 "2022-03-07T18:38:34Z")

</div>

Thanks @paul-griffith, I appreciate your help.
