Invoking a JPopupMenu from a JComboBox

Add a MouseListener:

import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import java.awt.*;
    
public class Main extends JFrame
{ 
   public Main() {
      getContentPane().setLayout(new FlowLayout());
      
      final JComboBox combobox = new JComboBox(new String[] { "Item 1", "Item 2", "Item 3" });
      final JPopupMenu popup = new JPopupMenu();
      JMenuItem mi1 = new JMenuItem("Popup Item 1");
      JMenuItem mi2 = new JMenuItem("Popup Item 2");
      popup.add(mi1);
      popup.add(mi2);
 
      ((JButton) combobox.getComponent(0)).addMouseListener(new MouseAdapter() {
         public void mousePressed(MouseEvent me) {
            if (me.isPopupTrigger()) {
               popup.show(combobox, me.getX(), me.getY());
            }
         }
 
         public void mouseReleased(MouseEvent me) {
            if (me.isPopupTrigger()) {
               popup.show(combobox, me.getX(), me.getY());
            }
         }
      });
 
      getContentPane().add(combobox);
  
      addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent we) {
            System.exit(1);
         }
      });      
   
      setSize(new Dimension(200, 200));
   } 
 
   public static void main(String[] args) throws Exception {
      Main main = new Main();
      main.setVisible(true);
   }
}