anu johncy wrote:But the Paint(Graphics g){ } is not executing , the button click event is woking
Did you perhaps create a subclass of some Swing class and try to override its
paint(Graphics g) method? If that's the case then you didn't spell the name of the method correctly. Java is a case-sensitive language so a method named "Paint" doesn't override one called "paint". You can avoid this situation by using the
@Override annotation, like this:
This code should give you a compiler error saying that Paint(Graphics) doesn't override any method in JPanel.