I am trying to implement a GUI using Java. I am by no means a professional programmer.
My GUI contains a JTable ("tlbPoints") with an associated JPopupMenu ("popupMenu") that becomes visible every time I right-click on tblPoints.
The elements of tblPoints are simply strings.
I managed to write a Mouse Listener associated with popupMenu which recognizes the item of the popupMenu that has been selected but does not know which string of tblPOints has been picked.

There are two choices:
(1) selection of a string (row) on tblPoints
(2) selection of an item on popupMenu

Do I need two events with relative actions? That is two mouse clicks? Or can the two above-mentioned choices be carried out with one click only and with only one Action Listener?
How can I write an Action Listener, associated with tblPoints, which gets the selected string and passes it to the Mouse Listener triggered by a mouse right-click?

I am posting my GUI. Sorry for the redundant code. I am a Java beginner.
I am providing the link to a picture of my GUI uploaded to GoogleDrive. I do hope you can see it.
Thank you

import java.awt.EventQueue;
 
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.border.EmptyBorder;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.border.EtchedBorder;
import java.awt.Color;
import java.awt.Font;
import java.awt.Dimension;
import java.awt.Point;
import javax.swing.UIManager;
import java.awt.Rectangle;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.ListSelectionModel;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import javax.swing.border.SoftBevelBorder;
import javax.swing.border.BevelBorder;
import javax.swing.JScrollPane;
import javax.swing.JList;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.AbstractListModel;
import javax.swing.DefaultListModel;
 
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Component;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Vector;
 
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
 
import java.awt.Point;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
 
//--------- Define ActionListener
class PopupActionListener implements ActionListener    // NOT USED
{
	public void actionPerformed(ActionEvent actionEvent) {
	 System.out.println("Selected: " + actionEvent.getActionCommand());
}
}
 
 
public class MyNewGUI extends JFrame 
{
 
// INSTANCE VARIABLE/COMPONENTS
		private JPanel ctpMain;
		private JTextField txtNewPoint;
		private JLabel lblNewPoint;
		private JButton btnNewPoint;
		private JButton btnDeleteAll;
		private JButton btnDeleteUnused;
		private JScrollPane scrPoints;
		private JButton btnExit;
		DefaultTableModel pointsTableModel = new DefaultTableModel ();
		JTable tblPoints = new JTable(pointsTableModel);
		JPopupMenu popupMenu = new JPopupMenu();
		JMenuItem menuItemAddBefore;
		JMenuItem menuItemAddAfter;
		JMenuItem menuItemRemove;
		JMenuItem menuItemRename;
 
/**************************** Launch the application *********************************************/
	public static void main(String[] args) 
	{
		try 
		{
			UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
		} catch (Throwable e) 
		{
			e.printStackTrace();
		}
		EventQueue.invokeLater(new Runnable()
		{
			public void run() 
			{
				try
				{
					MyNewGUI frame = new MyNewGUI();
					frame.setVisible(true);
				} catch (Exception e) 
				{
					e.printStackTrace();
				}
			}
		});
	}
 
 
//**************************  JFrame Class Constructor --> Create the frame   ***************************                                                                                                                                                                                                                                                                                                                                                    	 */
	public MyNewGUI() 
	{
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(new Rectangle(10, 10, 100, 100));
		setMinimumSize(new Dimension(100, 100));
		setFont(new Font("Arial", Font.BOLD, 16));
		setBounds(1050,200,800,800);
		setTitle("MyNewGUI");
		initComponents();
 
		btnExit = new JButton("Exit GUI");
		btnExit.setFont(new Font("Arial", Font.BOLD, 16));
		btnExit.setBounds(14, 254, 101, 26);
		ctpMain.add(btnExit);
		setVisible(true);
		createEvents();
	}
 
	/////////////////////////////////////////////////////////////////////////////////////////////////////////
	//  This method contains all of the code for creating and initializing components
	/////////////////////////////////////////////////////////////////////////////////////////////////////////
	private void initComponents()
	{
		setTitle("MyGUI");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 1041, 779);
		ctpMain = new JPanel();
		ctpMain.setBounds(new Rectangle(5, 5, 0, 0));
		ctpMain.setAlignmentY(5.0f);
		ctpMain.setAlignmentX(5.0f);
		ctpMain.setSize(new Dimension(10, 10));
		ctpMain.setPreferredSize(new Dimension(100, 100));
		ctpMain.setLocation(new Point(10, 10));
		ctpMain.setFont(new Font("Arial", Font.BOLD, 16));
		ctpMain.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		setContentPane(ctpMain);
 
		btnNewPoint = new JButton("Add New Point");
 
		btnNewPoint.setBounds(14, 55, 167, 29);
		btnNewPoint.setFont(new Font("Arial", Font.BOLD, 16));
 
		txtNewPoint = new JTextField();
		txtNewPoint.setBounds(162, 14, 144, 29);
		txtNewPoint.setFont(new Font("Arial", Font.BOLD, 16));
		txtNewPoint.setColumns(10);
 
		lblNewPoint = new JLabel("  Point Identifier");
		lblNewPoint.setLocation(new Point(14, 19));
		lblNewPoint.setSize(new Dimension(136, 19));
		lblNewPoint.setDisplayedMnemonicIndex(1);
		lblNewPoint.setAutoscrolls(true);
		lblNewPoint.setFont(new Font("Arial", Font.BOLD, 16));
 
		JTextArea textArea = new JTextArea();
		textArea.setBounds(179, 197, 1, 16);
		textArea.setText("");
 
		JPanel pnPoints = new JPanel();
		pnPoints.setBounds(321, 21, 211, 668);
		pnPoints.setFont(new Font("Arial", Font.BOLD, 24));
		pnPoints.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "", TitledBorder.CENTER, TitledBorder.TOP, null, new Color(64, 0, 64)));
		ctpMain.setLayout(null);
		ctpMain.add(btnNewPoint);
		ctpMain.add(txtNewPoint);
		ctpMain.add(lblNewPoint);
		ctpMain.add(textArea);
		ctpMain.add(pnPoints);
		pnPoints.setLayout(null);
 
		scrPoints = new JScrollPane();
		scrPoints.setBounds(0, 0, 206, 668);
		pnPoints.add(scrPoints);
 
// --------- Initialize JTable Model with points fromCliff's code
		pointsTableModel.addColumn("Point Names");
		pointsTableModel.insertRow(0, new Object[] { "ONE" });
		pointsTableModel.insertRow(0, new Object[] { "TWO" });	 
		pointsTableModel.insertRow(0, new Object[] { "THREE" });	 
		scrPoints.setViewportView(tblPoints);
		tblPoints.setFocusable(true);
		tblPoints.setRowSelectionAllowed(true);
		tblPoints.setVisible(true);
 
 
// --------- Initialize popupMenu with items ---
		PopupListener myListener = new PopupListener();
		menuItemAddBefore = new JMenuItem("Add Point Before");
		menuItemAddBefore.addMouseListener(myListener);
		menuItemAddAfter = new JMenuItem("Add Point After");
		menuItemAddAfter.addMouseListener(myListener);
		menuItemRemove = new JMenuItem("Remove Current Point");
		menuItemRemove.addMouseListener(myListener);
		menuItemRename = new JMenuItem("Rename Current Point");
		menuItemRename.addMouseListener(myListener);
		popupMenu.add(menuItemAddBefore);
		popupMenu.add(menuItemAddAfter);
		popupMenu.add(menuItemRemove);
		popupMenu.add(menuItemRename);
 
// --------- Set popupMenu to tblPoints
		tblPoints.setComponentPopupMenu(popupMenu);	
		tblPoints.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
 
		btnDeleteAll = new JButton("Delete All Points");
		btnDeleteAll.setFont(new Font("Arial", Font.BOLD, 16));
		btnDeleteAll.setBounds(14, 192, 167, 26);
		ctpMain.add(btnDeleteAll);
 
		btnDeleteUnused = new JButton("Delete Unused Points");
		btnDeleteUnused.setFont(new Font("Arial", Font.BOLD, 16));
		btnDeleteUnused.setBounds(14, 126, 205, 26);
		ctpMain.add(btnDeleteUnused);
	}
 
/////////////////////////////////////////////////////////////////////////////////////////////////////////
//  This method contains all of the code for creating events
/////////////////////////////////////////////////////////////////////////////////////////////////////////
	private void createEvents() 
	{
 
//-------- Append Point To Point Names List ------------------------------------------------------------
		btnNewPoint.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e) 
			{
				String newPoint = txtNewPoint.getText();	
				pointsTableModel.addRow(new Object[] {newPoint});
				txtNewPoint.setText("");
			}
		});
 
//-------- Remove Unused Points From Point Names List ---------------------------------------------------
		btnDeleteUnused.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e)
			{
				// TO BE DEVELOPED
			}
		});
 
//-------- Empty Point Names List --------------------------------------------------------------------------		
		btnDeleteAll.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e) 
			{
				while (pointsTableModel.getRowCount() > 0) 
					pointsTableModel.removeRow(0);
			}
		});
 
 
//--------------- Button EXIT Handler --------------------------------------------------------------------------------------------------------------------
		btnExit.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e) 
			{
				Object[] options = {"Exit Without Saving", "Exit With Saving","Cancel"};    	//Custom button text
				int sel = JOptionPane.showOptionDialog(null ,
				    "Would you like to save your work before exiting ? ",
				    "EXIT WORK SESSION",
				    JOptionPane.YES_NO_CANCEL_OPTION,
				    JOptionPane.QUESTION_MESSAGE,
				    null,
				    options,
				    options[2]);
// Process Customer's Selection
				if (sel == 0) 
				{
					 JOptionPane.showMessageDialog(null, "You chose to exit your work session without saving!");
					 System.exit(0);	
				}
				if(sel == 1) 
				{
					 JOptionPane.showMessageDialog(null, "You chose to save your work session before exiting !");
//					 if(lstPoints != null && !pointsTableModel.isEmpty())  // If JList contains Points
//					 {
//						 pointsList.clear();     // Empty Points storage
//						 System.out.print("\n pointsList after clear():  " + pointsList);       // DEBUG-PURPOSE
//						 System.out.print("\n pointsTableModel :  " + pointsTableModel);         // DEBUG-PURPOSE
//						 System.out.print("\n pointsTableModel size:  " + pointsTableModel.size() );        // DEBUG-PURPOSE
//						 System.out.print("\n");
//						 for(int i=0; i < pointsTableModel.size(); i++)
//							 pointsList.add(pointsTableModel.get(i));    // Move Points from JList to Points storage
//						 System.out.print("Saved Points:  " + pointsList + "\n");
//					 }else 
//						 JOptionPane.showMessageDialog(null, "Your Ponts List is empty!"); 
//					 System.exit(0);	
				}
				if(sel == 2) 
					 JOptionPane.showMessageDialog(null, "You changed your mind !");
			}
		});
 
	}  //-----------------------------------  End Of  createEvents() Method ----------------------------------------------------------------------	
 
// ********* Inner classes *********
 
	public class PopupListener extends MouseAdapter
	{
		 private JMenuItem m_popup;
 
		 public PopupListener()                 //  Default Constructor
		 {
	 	    System.out.print("\n Default PopupListener engaged \n ");
		 }
 
		 public PopupListener(JMenuItem menu)        //  Overloaded Constructor
		 {
		 	m_popup = menu;
	 	    System.out.print("\n PopupListener engaged \n ");
		 }
 
		 public void mousePressed(MouseEvent e) 
		 {
			  Component whichItem = e.getComponent();
			  if(whichItem instanceof JMenuItem) 
			  {
				  JMenuItem mni = (JMenuItem) whichItem;
	 		      String text = mni.getText();
				  System.out.print("Component Text:  " + text + "\n");
			  }
		 }
	}
}

[IMG] https://drive.google.com/file/d/1qdj...usp=share_link [/IMG]