This is s program that allows a user to draw shapes by inputting the specifications(size, location, color etc). The user can select a shape and edit or delete it after creating it. I created JLabels and added MouseListeners to them. These JLabels are created when the main program runs but they are not shown yet. When a user creates/draws a shape, a label's setText is set and the label is displayed(the arrayList is updated as well). The problem is that I dont know how many shapes the user is going to create, so I dont know how many labels I need. And all these labels need MouseListeners because clicking on a label means selecting the shape associated with. So you can click on a label and you will be able to edit or delete the shape associated that label. I tried creating the labels in the actionEvent method for the shapes but they cannot be displayed if i create them there.
Oh! Actually I posted the same question in about 5 Forums but I didn't know that was not a good idea. I didn't know I should mention that I did post it somewhere else. I registered in all these forums because I want to finish this program ASAP and i thought getting response from different Forums might be quicker and more helpful. Thanks for letting me know anyway, the reasons mentioned makes sense.
subject: Adding JLabels to JPanel as user creates Shapes