From your comment, it looks like you are trying to display a submenu in the popup that appears above your JTextField.
JTextField textField = new JTextField();
JPopupMenu popup = new JPopupMenu();
textField.add(popup);
textField.setComponentPopupMenu(popup);
JMenu subMenu = new JMenu("m");
subMenu.add("m1");
subMenu.add("m2");
popup.add(subMenu);
popup.add("n");
I hope I answered the question you are trying to ask. If you could not explain a little more about what you are trying to accomplish?
source
share