How can I add a button to paintComponent panel in java?
问题 The app is an option menu which shows a drawing depending on which button the user presses. I have a container panel with a CardLayout which manages the other panels. I want to show the drawing in my paintComponent Panel, but I also want a button at the bottom of the screen so the user can go back to the main menu. I tried adding it like this but the button didn't appear: CardLayout c1 = new CardLayoutl; JPanel cont1 = new JPanel(); cont1.setLayout(c1); JPanel panel1 = new JPanel(); panel1