I have a custom JPanel
class which I add to my Frame
and constantly update. This class has an overidden paintComponent
and a JButton
. How do I draw the JButton
over my graphics drawn in my paintComponent
? I constantly update this paintCompoment
through a loop which repaint()
's it, But I do not change the JButton
. My custom JPanel
class is a subclass of my Main
class.
My Panel Class
public class interTower extends JPanel implements ActionListener{
public interTower(){
setVisible(true);
setPreferredSize(new Dimension(SCREENWIDTH, SCREENHEIGHT));
JButton interTower_back = new JButton("Back");
interTower_back.setActionCommand("interTower_back");
interTower_back.addActionListener(this);
add(interTower_back);
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
drawMaster(g2d);
g2d.dispose();
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}
}