Can you change the order of JMenuItems?

76 Views Asked by At

This a really straightforward question. Can I change the order of JMenuItems in a JPopupMenu? Or is there a way to specify something like an index when adding a menu item to a popup menu like you can with a list (e.i. List.add(int, Object))?

Context: I have an abstract class which is adding a menu item to a popup menu in the super constructor. I want to insert menu items before that item in the child class' constructor.

Any easy way to do this?

1

There are 1 best solutions below

1
Gerhard On BEST ANSWER

Have you tried the following method of JPopupMenu?

void insert(Component component, int index)