I have a custom made JPanel itemSmallCard(String prodID, String productName, String price, String retailer)
, using this I created multiple instances of it in another JPanel with different parameters on the ActionPerformed event of a button as follows:
JPanel iC = new itemSmallCard("123456789ab", "Inspiron 7567 Intel Core i5 DELL Laptop", "48957", "Cloudtail Pvt. Ltd.");
mainContentPane.add(iC);
mainContentPane.revalidate();
mainContentPane.repaint();
However as all the new JPanels were created with this same code using the same variable iC
, I don't know how to access a particular JPanel variable from them, thus also unable to access its event listeners.
How can I achieve that?