I have not mastered the right-click menu in some components for a long time, and I have always felt quite difficult (it really seems that I am stupid, but I am in a daze spirit, and I succeeded today, but it will be nice to understand it later. So let's take a look at it and share it with you. 1: define variables. Jlist; jpopupmenu; jmenuitem; jsonjradiobuttonmenuitem; jcheckboxmenuitem; jseparator; 2: Initialize member variables. Saving, no writing. 3: Right-click the jpopupmenu menu to add jlist1.add (jpopupmenu) in the list (jlist); 4: add the mouse listener jlist for the jlist. addmouselistener (New myjlistlistener (); 5: implement the mouse listener public class myjlistlistener extends mouseadapter {// E. getbutton () returns 1, 2, 3. 1 indicates the left mouse button, 3 indicates the right mouse button // jlist. getselected () returns the number of items in the selected jlist. // If statement, that is, right-click in jlist and select an item in jlist. The right-click menu is displayed. // E. getx (), E. gety () returns the current cursor position! That is, right-click public void mouseclicked (mouseevent e) {If (E. getbutton () = 3 & jlist. getselected ()> = 0) jpopupmenu. show (jlist, E. getx (), E. gety () ;}} now understands that adding right-clicking other components is the same. It seems much easier to separate things!