How to get a JTextField event that started a pop up menu in Java?

Read the section from the Swing tutorial on How to Use Menus for working examples. The MouseListener is only used to display the popup, not handle the selection of the menu item. You need to add an ActionListener to each menu item to handle the selection.

You are getting the ClassCastException because the mouselistener is not on the JTextField but on the JMenuItem. They're 2 distinct components not related to each other so the JMenuItem doesn't know that the JTextField 'started it', so unless you do the association yourself you can't really achieve this directly.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions