# Popup menun

**URL:** <https://forum.inductiveautomation.com/t/popup-menun/5939>\
**Category:** Ignition\
**Created:** [February 28, 2013, 2:01pm UTC](https://forum.inductiveautomation.com/t/popup-menun/5939 "2013-02-28T14:01:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![djones](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@djones](https://forum.inductiveautomation.com/u/djones)\
**Post date:** [February 28, 2013, 2:01pm UTC](https://forum.inductiveautomation.com/t/popup-menun/5939/1 "2013-02-28T14:01:30Z")

</div>

I would like to modifiy some of the properties of the popup menu that is created from createPopupMenu. The returned type is of JPopupMenu. I can modify the border color by

```auto
menu.background = system.gui.color(255,0,0)
```

I am looking to modify the following attributes for the popup:  
Background color (not just the border)  
Fill Area  
width  
text wrapping

Also, Is there a way to add a separator? I can use the following to add a separator after the menu is created

```auto
menu.addSeparator()
```

But I cannot seem to add anything after the separator that has a function. The following code can adds a separator and another menu item called “XXX”

```auto
menu.addSeparator()
menu.add("XXX")   
```

The problem is that there is no function associated with the “XXX” menu item. I have tried the following, but all with errors:

```auto
menu.addSeparator()
menu.add("XXX",doMenuItem1)   

The code below generates a popup menu on the clicked event of a button.

menu.addSeparator()
menu.add({"XXX":doMenuItem1}) 
```

```auto

m = []
f = []

def doMenuItem1(event):
    import system
    system.gui.messageBox("Report 1 selected")
def doMenuItem2(event):
	import system
	system.gui.messageBox("Report 2 selected")
def doMenuItem3(event):
	import system
	system.gui.messageBox("Report 3 selected")

import system

m.append("Report 1")
m.append("Report 2")
m.append("Report 3")

f.append(doMenuItem1)
f.append(doMenuItem2)
f.append(doMenuItem3)

menu = system.gui.createPopupMenu(m,f)

menu.background = system.gui.color(255,0,0)

menu.show(event,event.source.parent.x,event.source.parent.y+25)

```

---

<div class="post-metadata">

**Author:** ![djones](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@djones](https://forum.inductiveautomation.com/u/djones)\
**Post date:** [February 28, 2013, 3:13pm UTC](https://forum.inductiveautomation.com/t/popup-menun/5939/2 "2013-02-28T15:13:51Z")

</div>

Figured it out:

Turns out i needed to create each java menuitem and assign the properties to each. Then add all the java menu items to the JPopupMenu that is returned from the createPopupMenu.

Here were some useful links:

[http://docs.oracle.com/javase/6/docs/api/javax/swing/JComponent.html#getInsets()](http://docs.oracle.com/javase/6/docs/api/javax/swing/JComponent.html#getInsets())  
[http://www.java2s.com/Tutorial/Java/0240\_\_Swing/CustomizingJMenuItemLookandFeel.htm](http://www.java2s.com/Tutorial/Java/0240__Swing/CustomizingJMenuItemLookandFeel.htm)

```auto
from javax.swing import JMenuItem
from javax.swing.border import EmptyBorder

def doMenuItem1(event):
    import system
    system.gui.messageBox("Report 1 selected")
def doMenuItem2(event):
	import system
	system.gui.messageBox("Report 2 selected")
def doMenuItem3(event):
	import system
	system.gui.messageBox("Report 3 selected")

import system

menu = system.gui.createPopupMenu([],[])

menuitem1 = JMenuItem ("Report 1",actionPerformed=doMenuItem1)
menuitem1.background = system.gui.color(0,0,0)
menuitem1.foreground = system.gui.color(255,255,255)
menu.add(menuitem1)

menuitem2 = JMenuItem ("Report 2",actionPerformed=doMenuItem2)
menuitem2.background = system.gui.color(0,0,0)
menuitem2.foreground = system.gui.color(255,255,255)
menu.add(menuitem2)

menu.addSeparator()

menuitem3 = JMenuItem ("Report 3",actionPerformed=doMenuItem3)
menuitem3.background = system.gui.color(0,0,0)
menuitem3.foreground = system.gui.color(255,255,255)
menu.add(menuitem3)

menu.setPopupSize(150, 25*3)
menu.setBackground(system.gui.color(0,0,0))

menu.show(event,event.source.parent.x,event.source.parent.y+25)

```

---

<div class="post-metadata">

**Author:** ![dave.fogle](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@dave.fogle](https://forum.inductiveautomation.com/u/dave.fogle)\
**Post date:** [March 4, 2013, 5:31pm UTC](https://forum.inductiveautomation.com/t/popup-menun/5939/3 "2013-03-04T17:31:23Z")

</div>

Glad you got it figured out.
