How to dynamically remove a JPanel?
I have a a GUI looks as follow. I want to dynamically add/remove a panel. I use ArrayList to keep trace of JPanel objects. And now I could add panel dynamically, but when I want to delete a panel, I could not get its attribute so that I can not remove it. Here is my code: public class Main implements ActionListener{ private List <myPanel> mpList; private JPanel btnPanel; private JButton jbtAdd,jbtDelete; private JFrame jf; private JPanel jp; private JScrollPane js; private myPanel mp; private static int size=0; private int selectedId=-1; //private public Main(){ mpList=new ArrayList<myPanel>()